mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-13 00:24:28 +00:00
ddb6c460ff
* use ES Modules * Fix some bugs * add Novice Gather
28 lines
649 B
JavaScript
28 lines
649 B
JavaScript
import { Schema, model } from "mongoose";
|
|
|
|
var archivedGatherSchema = new Schema({
|
|
createdAt: { type: Date, default: Date.now },
|
|
gather: { type: Schema.Types.Mixed, required: true }
|
|
});
|
|
|
|
archivedGatherSchema.index({ createdAt: -1 });
|
|
|
|
archivedGatherSchema.static({
|
|
recent: function (callback) {
|
|
this
|
|
.where({})
|
|
.sort({ createdAt: -1 })
|
|
.limit(5)
|
|
.exec(callback);
|
|
},
|
|
archive: function (gather, callback) {
|
|
// Do not try to fix this
|
|
// failed attempts to fix this: 1
|
|
let data = JSON.parse(JSON.stringify(gather.toJson()));
|
|
this.create({
|
|
gather: data
|
|
}, callback);
|
|
}
|
|
});
|
|
|
|
model("ArchivedGather", archivedGatherSchema);
|