]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/user.js
Server: reorganize express validators
[github/Chocobozzz/PeerTube.git] / server / models / user.js
CommitLineData
69b0a27c
C
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 = {
2f372a86
C
14 getByUsernameAndPassword: getByUsernameAndPassword,
15 list: list
69b0a27c
C
16}
17
18mongoose.model('User', UserSchema)
19
20// ---------------------------------------------------------------------------
21
22function list (callback) {
23 return this.find(callback)
24}
25
2f372a86
C
26function getByUsernameAndPassword (username, password) {
27 return this.findOne({ username: username, password: password })
69b0a27c 28}