Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 3x 3x 3x 3x 3x 3x 3x 3x | 'use strict'
const mongoose = require('mongoose')
const paginate = require('../../libs/plugins/paginate')
const autopopulate = require('../../libs/plugins/autopopulate')
const Schema = mongoose.Schema
const schema = new Schema({
user: { // 主动
type: Schema.Types.ObjectId,
ref: 'User',
required: true,
autopopulate: { select: 'email username role',
// {
// email:1,
// username:1,
// }
},
},
target: { // 被动
type: Schema.Types.ObjectId,
refPath: 'ref',
required: true,
},
ref: {
type: String,
required: true,
},
content: {
type: String,
trim: true,
alias: 'remark',
},
}, {
timestamps: {},
toObject: { virtuals: true },
id: false,
})
schema.plugin(paginate);
schema.plugin(autopopulate);
module.exports = mongoose.model('Logs', schema) |