Answer the question
In order to leave comments, you need to log in
How to store data correctly in mongoose?
Schema itself
var Marker = mongoose.Schema({
date: Date,
time: Date,
place: String,
theme: Number,
peopleCount: Number,
creator: { type: Schema.Types.ObjectId, ref: 'User' },
persons: [{ type: Schema.Types.ObjectId, ref: 'User' }],
description: {
type: String,
}
});
exports.update = function(data, fn) {
Marker.findOne({ _id: data.params.id }, function(err, marker) {
if(err) throw err;
_.extend(marker, data.body);
console.log(marker);
marker.save(function(err, marker) {
if (err) throw err;
fn(marker);
});
});
};
Answer the question
In order to leave comments, you need to log in
Validation is down. Try doing console.log(err.errors) to see a list of errors.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question