var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var notificationsSchema = mongoose.Schema({
"datetime" : {
type: Date,
default: Date.now
},
"ownerId":{
type:String
},
"customerId" : {
type:String
},
"title" : {
type:String
},
"message" : {
type:String
}
});
var notifications = module.exports = mongoose.model('notifications', notificationsSchema);
module.exports.saveNotification = function(notificationObj, callback){
//notifications.insert(notificationObj); won't work
//notifications.save(notificationObj); won't work
notifications.create(notificationObj); //work but created duplicated document
}
कोई विचार क्यों मेरे मामले में सम्मिलित और सहेजना नहीं है? मैंने बनाने की कोशिश की, यह 1 के बजाय 2 दस्तावेज़ डाला। यह अजीब बात है।mongoose save vs बनाम बनाम बनाम बनाम
यह आपकी मदद नहीं करता है जब आप एक ही समस्या को कई बार पोस्ट करते हैं http://stackoverflow.com/questions/38290506/mongoose-create-created-multiple-document ... – DAXaholic
@DAXaholic क्या आपकी कोई समस्या है ? –
@ मारियाजेन क्यूड आप 'अधिसूचना ओबीजे' के रूप में पारित वस्तु की घोषणा दिखाते हैं। – Iceman