30 lines
984 B
JavaScript
30 lines
984 B
JavaScript
const mongoose = require('mongoose');
|
|
const mongoosePaginate = require('mongoose-paginate-v2');
|
|
|
|
function image(img) {
|
|
if (img) return '/uploads/images/users/' + img
|
|
}
|
|
|
|
const AdminSchema = mongoose.Schema({
|
|
firstName: String,
|
|
lastName: String,
|
|
password: String,
|
|
scope: {type: Array, default: ['admin']},
|
|
token: {type: String, default: null},
|
|
profilePic: {type: String, get: image, default: null},
|
|
mobileNumber: {type: String, default: null},
|
|
email: String,
|
|
registration_done: {type: Boolean, default: false},
|
|
_creator: {type: mongoose.Schema.Types.ObjectId, ref: 'User'},
|
|
_updatedBy: {type: mongoose.Schema.Types.ObjectId, ref: 'User'},
|
|
username: {type: String, unique: true},
|
|
portals: {type: Array, default: []},
|
|
permissions: Array,
|
|
specialPermissions: [{type: mongoose.Schema.Types.ObjectId, ref: 'Category'}],
|
|
private: {type: Boolean, default: false}
|
|
})
|
|
|
|
AdminSchema.plugin(mongoosePaginate);
|
|
|
|
module.exports = mongoose.model('User', AdminSchema)
|