im working with mongoose. i am trying to update my Contact module:
var ContactSchema = mongoose.Schema({
name : String,
phone : String,
id : String,
plans : [{
name : String
}] });
in my code i do:
var uuid = require('node-uuid');
var url = require("url");
var mongoose = require('mongoose');
var querystring = require("querystring");
var Contact = mongoose.model('Contact', require('D:/DEVELOPMENT/ANDROID_WORKSPACE/HapiServer/models/ContactSchema'));
function handle(req, replay) {
var b = req.payload;
var excistingPhones = [];
var length = b.invitedList.length;
b.invitedList.forEach(function(value) {
console.log("plan: "+b.name);
var query = { phone: value.phone };
Contact.update(query, {
$push : {
plans : {
name: b.name
}
}
});
});
}
exports.handle = handle;
i tried doing simple change to the database:
Contact.update (query,
{
$set: { id: '11111' }
});
but no reaction.
any idia why my db wont change?
thank you.
UPDATE-SOLUTION FOUND:
i found the solution. the update didnt work. so i did find function and then i changed the contact instance i found inside the find function and saved.