user.js
766 Bytes
'use strict';
const mysqlCli = global.yoho.utils.mysqlCli;
const TABLE_USER = 'user';
class UserModel extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
getUser(mobile) {
return mysqlCli.query(`select * from ${TABLE_USER}
where user_phone=:mobile`, {
mobile
});
}
createUser({name, mobile, avatar}) {
name = name || '';
mobile = mobile || '';
avatar = avatar || '';
return mysqlCli.insert(
`insert into ${TABLE_USER}
(user_phone, user_name, user_avatar) values (:mobile, :name, :avatar)`, {
name,
mobile,
avatar
});
}
}
module.exports = UserModel;