我是MEAN开发的小伙子,我想做一些像跟踪系统那样的事情来保存执行操作的用户,他做了哪个动作以及他修改过的对象。我想知道哪个类型必须是字段对象保存修改对象的更改并使用此模型保存所有集合的更改。
这是我的跟踪模型:
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var TraceSchema = new Schema({
user: {
type: Schema.ObjectId,
ref: 'User'
},
action: {
type: String,
required: true
},
object: {
// which type do i have to put here or how can i do this?
},
collection: {
type: String,
required: true
},
date:{
type:Date,
default: Date.now()
}
});
mongoose.model('Trace', TraceSchema);