var DB = require('../DB');
function User(user){
this.name=user.name;
this.password=user.password;
this.email=user.email;
}
module.exports.User=User;
//查询用户信息
User.get=function(name,callback){
DB.select("select * from users where username=$1",[name],function(err,result){
callback(err,result);
}
);
}
//存储用户信息
User.prototype.save=function(callback){
//要存入数据库的用户文档
var user={
name:this.name,
password:this.password,
email:this.email
}
DB.add("insert into users(name,password,email)values($1,$2,$3)",[user.name,user.password,user.email],callback);
}
function hello(Hello){
this.id=Hello.id;
this.name=Hello.name;
this.height=Hello.height;
}
module.exports.hello=hello;
hello.get=function(callback){
DB.select("select * from hello",[],function(err,result){
callback(err,result);
}
function User(user){
this.name=user.name;
this.password=user.password;
this.email=user.email;
}
module.exports.User=User;
//查询用户信息
User.get=function(name,callback){
DB.select("select * from users where username=$1",[name],function(err,result){
callback(err,result);
}
);
}
//存储用户信息
User.prototype.save=function(callback){
//要存入数据库的用户文档
var user={
name:this.name,
password:this.password,
email:this.email
}
DB.add("insert into users(name,password,email)values($1,$2,$3)",[user.name,user.password,user.email],callback);
}
function hello(Hello){
this.id=Hello.id;
this.name=Hello.name;
this.height=Hello.height;
}
module.exports.hello=hello;
hello.get=function(callback){
DB.select("select * from hello",[],function(err,result){
callback(err,result);
}
);
//使用
var User=require("../../datamodules/User");
function hello(req,res){
//打印函数名
var m_FuncJson=baseCall.GetRouteFuncJson(req,res);
User.User.get('xn ',function(err,result){
console.log(result);
res.send(m_FuncJson.call.name);
});
}