PeerTube/server/models/user.js

29 lines
678 B
JavaScript
Raw Normal View History

const mongoose = require('mongoose')
// ---------------------------------------------------------------------------
const UserSchema = mongoose.Schema({
password: String,
username: String
})
UserSchema.path('password').required(true)
UserSchema.path('username').required(true)
UserSchema.statics = {
2016-07-20 16:23:58 +02:00
getByUsernameAndPassword: getByUsernameAndPassword,
list: list
}
mongoose.model('User', UserSchema)
// ---------------------------------------------------------------------------
function list (callback) {
return this.find(callback)
}
2016-07-20 16:23:58 +02:00
function getByUsernameAndPassword (username, password) {
return this.findOne({ username: username, password: password })
}