ensl_gathers/db/models/archivedGather.js

24 lines
499 B
JavaScript
Raw Normal View History

2015-09-21 21:59:00 +00:00
"use strict";
var mongoose = require("mongoose");
var Schema = mongoose.Schema;
var archivedGatherSchema = new Schema({
createdAt: { type: Date, default: Date.now },
gather: { type: Schema.Types.Mixed, required: true }
});
archivedGatherSchema.index({ createdAt: -1 });
2015-09-22 18:48:57 +00:00
archivedGatherSchema.static({
recent: function (callback) {
this
.where({})
.sort({createdAt: -1})
.limit(5)
.exec(callback);
}
2015-09-21 21:59:00 +00:00
});
module.exports = mongoose.model("ArchivedGather", archivedGatherSchema);