aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/user.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/user.js')
-rw-r--r--server/models/user.js28
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 @@
1const mongoose = require('mongoose')
2
3// ---------------------------------------------------------------------------
4
5const UserSchema = mongoose.Schema({
6 password: String,
7 username: String
8})
9
10UserSchema.path('password').required(true)
11UserSchema.path('username').required(true)
12
13UserSchema.statics = {
14 list: list,
15 loadByUsernameAndPassword: loadByUsernameAndPassword
16}
17
18mongoose.model('User', UserSchema)
19
20// ---------------------------------------------------------------------------
21
22function list (callback) {
23 return this.find(callback)
24}
25
26function loadByUsernameAndPassword (username, password, callback) {
27 return this.findOne({ username: username, password: password }, callback)
28}