user.js
659 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
*
* @author: jiangfeng<jeff.jiang@yoho.cn>
* @date: 16/8/16
*/
'use strict';
const Model = require('./model');
const md5 = require('md5');
class User extends Model {
constructor() {
super('users');
}
async init() {
let count = await this.count({});
if (count === 0) {
await this.insert({
"username": "yoho",
"password": md5("yoho9646"),
"role": "1000",
"state": "1"
});
}
}
findByUsername(username) {
return this.findOne({
username: username
});
}
}
module.exports = User;