Skip to content
Snippets Groups Projects
Commit 7afbe975 authored by Markus Grigull's avatar Markus Grigull
Browse files

Add timestamps to other models

parent 0f1604d5
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,6 @@ var fileSchema = new Schema({ ...@@ -33,6 +33,6 @@ var fileSchema = new Schema({
dimensions: { type: Schema.Types.Mixed }, dimensions: { type: Schema.Types.Mixed },
user: { type: Schema.Types.ObjectId, ref: 'User', required: true }, user: { type: Schema.Types.ObjectId, ref: 'User', required: true },
date: { type: Date, default: Date.now } date: { type: Date, default: Date.now }
}, { versionKey: false }); }, { versionKey: false, timestamps: true });
module.exports = mongoose.model('File', fileSchema); module.exports = mongoose.model('File', fileSchema);
...@@ -33,7 +33,7 @@ var projectSchema = new Schema({ ...@@ -33,7 +33,7 @@ var projectSchema = new Schema({
user: { type: Schema.Types.ObjectId, ref: 'User', required: true }, user: { type: Schema.Types.ObjectId, ref: 'User', required: true },
visualizations: [{ type: Schema.Types.ObjectId, ref: 'Visualization', default: [] }], visualizations: [{ type: Schema.Types.ObjectId, ref: 'Visualization', default: [] }],
simulation: { type: Schema.Types.ObjectId, ref: 'Simulation', required: true } simulation: { type: Schema.Types.ObjectId, ref: 'Simulation', required: true }
}, { versionKey: false }); }, { versionKey: false, timestamps: true });
projectSchema.pre('remove', function(callback) { projectSchema.pre('remove', function(callback) {
// delete all visualizations belonging to this project // delete all visualizations belonging to this project
......
...@@ -30,6 +30,6 @@ const simulationModelSchema = new mongoose.Schema({ ...@@ -30,6 +30,6 @@ const simulationModelSchema = new mongoose.Schema({
outputMapping: { type: mongoose.Schema.Types.Mixed, default: {} }, outputMapping: { type: mongoose.Schema.Types.Mixed, default: {} },
inputMapping: { type: mongoose.Schema.Types.Mixed, default: {} }, inputMapping: { type: mongoose.Schema.Types.Mixed, default: {} },
startParameters: { type: mongoose.Schema.Types.Mixed, default: {} } startParameters: { type: mongoose.Schema.Types.Mixed, default: {} }
}, { versionKey: false }); }, { versionKey: false, timestamps: true });
module.exports = mongoose.model('SimulationModel', simulationModelSchema); module.exports = mongoose.model('SimulationModel', simulationModelSchema);
...@@ -38,7 +38,7 @@ var userSchema = new Schema({ ...@@ -38,7 +38,7 @@ var userSchema = new Schema({
mail: { type: String, default: "" }, mail: { type: String, default: "" },
simulations: [{ type: Schema.Types.ObjectId, ref: 'Simulation', default: [] }], simulations: [{ type: Schema.Types.ObjectId, ref: 'Simulation', default: [] }],
files: [{type: Schema.Types.ObjectId, ref: 'File', default: [] }] files: [{type: Schema.Types.ObjectId, ref: 'File', default: [] }]
}, { versionKey: false }); }, { versionKey: false, timestamps: true });
userSchema.methods.verifyPassword = function(password, callback) { userSchema.methods.verifyPassword = function(password, callback) {
bcrypt.compare(password, this.password, function(err, isMatch) { bcrypt.compare(password, this.password, function(err, isMatch) {
......
...@@ -31,6 +31,6 @@ var visualizationSchema = new Schema({ ...@@ -31,6 +31,6 @@ var visualizationSchema = new Schema({
widgets: { type: Array, default: [] }, widgets: { type: Array, default: [] },
grid: { type: Number, default: 1 }, grid: { type: Number, default: 1 },
user: { type: Schema.Types.ObjectId, ref: 'User', required: true } user: { type: Schema.Types.ObjectId, ref: 'User', required: true }
}, { versionKey: false }); }, { versionKey: false, timestamps: true });
module.exports = mongoose.model('Visualization', visualizationSchema); module.exports = mongoose.model('Visualization', visualizationSchema);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment