const mongoose = require('mongoose')
const customUsersValidators = require('../helpers/custom-validators').users
+const modelUtils = require('./utils')
// ---------------------------------------------------------------------------
const UserSchema = mongoose.Schema({
+ createdDate: {
+ type: Date,
+ default: Date.now
+ },
password: String,
username: String,
role: String
}
UserSchema.statics = {
+ countTotal: countTotal,
getByUsernameAndPassword: getByUsernameAndPassword,
- list: list,
+ listForApi: listForApi,
loadById: loadById,
loadByUsername: loadByUsername
}
// ---------------------------------------------------------------------------
+function countTotal (callback) {
+ return this.count(callback)
+}
+
function getByUsernameAndPassword (username, password) {
return this.findOne({ username: username, password: password })
}
-function list (callback) {
- return this.find(callback)
+function listForApi (start, count, sort, callback) {
+ const query = {}
+ return modelUtils.listForApiWithCount.call(this, query, start, count, sort, callback)
}
function loadById (id, callback) {