3
0
Fork 0
xnode/lib-build/debug-server/node_lib/model/xsystem-session.js

36 lines
870 B
JavaScript
Raw Normal View History

2022-11-13 00:46:38 +00:00
var logger = require('winston').loggers.get('main');
var mongoose = require('mongoose');
var tmongoose = require('../lib/node-ff-tcrud').build.backend.mongoose;
var modelName = __filename.split('/').pop().split('.')[0];
var modelBackend = modelName.split('-').join('_');
var modelMeta = {
_id: {
type: String,
tfield: {
tname: 'SID',
ttype: 'textarea'
}
},
session: {
type: String,
tfield: {
ttype: 'textarea'
}
},
expires: {
type: Date,
},
};
var modelSchema = new mongoose.Schema(modelMeta);
modelSchema.statics = tmongoose.buildStaticsModelValidated(modelMeta,modelSchema, {
findLastChangedLimit5: function (callback) {
logger.debug(modelBackend+'.findLastChangedLimit5');
this.find({}).sort('-changed_date').limit(5).exec(callback);
},
});
module.exports = mongoose.model(modelName, modelSchema, modelBackend);