2017-06-23 18:00:27 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Module dependencies
|
|
|
|
|
*/
|
|
|
|
|
var mongoose = require('mongoose'),
|
|
|
|
|
Schema = mongoose.Schema;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Log Schema
|
|
|
|
|
*/
|
|
|
|
|
var TraceSchema = new Schema({
|
2017-06-24 12:36:28 +08:00
|
|
|
user: {
|
2017-06-23 18:00:27 +08:00
|
|
|
type: Schema.Types.ObjectId,
|
|
|
|
|
ref: 'User'
|
|
|
|
|
},
|
|
|
|
|
content: Object, //log json object
|
|
|
|
|
createdat: {
|
|
|
|
|
type: Date,
|
|
|
|
|
default: Date.now
|
|
|
|
|
}
|
2017-12-15 09:17:41 +08:00
|
|
|
}, {usePushEach: true});
|
2017-06-23 18:00:27 +08:00
|
|
|
|
2017-12-23 17:26:39 +08:00
|
|
|
TraceSchema.index({createdat: -1});
|
2017-12-26 18:33:22 +08:00
|
|
|
TraceSchema.index({'content.action': 1, createdat: -1});
|
2017-12-23 17:26:39 +08:00
|
|
|
|
2017-06-23 18:00:27 +08:00
|
|
|
mongoose.model('Trace', TraceSchema);
|