diff options
Diffstat (limited to 'server/models/user.js')
-rw-r--r-- | server/models/user.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/server/models/user.js b/server/models/user.js new file mode 100644 index 000000000..130b49b55 --- /dev/null +++ b/server/models/user.js | |||
@@ -0,0 +1,28 @@ | |||
1 | const mongoose = require('mongoose') | ||
2 | |||
3 | // --------------------------------------------------------------------------- | ||
4 | |||
5 | const UserSchema = mongoose.Schema({ | ||
6 | password: String, | ||
7 | username: String | ||
8 | }) | ||
9 | |||
10 | UserSchema.path('password').required(true) | ||
11 | UserSchema.path('username').required(true) | ||
12 | |||
13 | UserSchema.statics = { | ||
14 | list: list, | ||
15 | loadByUsernameAndPassword: loadByUsernameAndPassword | ||
16 | } | ||
17 | |||
18 | mongoose.model('User', UserSchema) | ||
19 | |||
20 | // --------------------------------------------------------------------------- | ||
21 | |||
22 | function list (callback) { | ||
23 | return this.find(callback) | ||
24 | } | ||
25 | |||
26 | function loadByUsernameAndPassword (username, password, callback) { | ||
27 | return this.findOne({ username: username, password: password }, callback) | ||
28 | } | ||