MongoDB - "The dollar ($) prefixed field \'$$hashKey\' in \'fieldName".$$hashKey\' is not valid for storage.'" -


while trying update document i'm getting above error field timestodisplay.

mongodb version 2.6.7.

the whole model:

msg = {           'name': '',           'template': '',           'displaydurinmillisec': 0,           'timestodisplay': [],           'images': [],           'texts': [],           'screen': []        } 

i guess getting same error other 3 array fields.

i've tried using $set sill getting same error.

the code:

function updatemessage(msg) {     var conditions = {_id: msg._id}       , update = { 'name': msg.name,                    'template': msg.template,                    'displaydurinmillisec': msg.displaydurinmillisec,                    'timestodisplay': msg.timestodisplay,                    'images': msg.images,                    'texts': msg.texts,                    'screen': msg.screen     }      messagemodel.update(conditions, update, callback);      function callback(err, numaffected) {         if (!err) console.log(numaffected)         else console.log(err)     } } 

edit: msg parameter document in itself:

{ _id: '557d58abd54955480db6694f',   name: 'msg99',   timestodisplay: [ { startdate: '2015-06-19t21:00:00.000z',                    '$$hashkey': 'object:214',                     enddate: '2015-06-25t21:00:00.000z',                     daysoftheweek: [object],                     starttimeofday: '11',                     endtimeofday: '13' } ],  images: [],  texts: [],  screen: [ 1 ],  '$$hashkey': 'object:54',  displaydurinmillisec: '40189',  template: 'templates/template2.html' } 

the $$hashkey field added angularjs when working ngrepeat or ngoptions. in case of ngrepeat can change repeat string appending track $index it. using ngoptions you'll have filter out field yourself. angularjs provides quick solution filtering out: angular.tojson. filter out fields prefixed 2 dollar signs. check out documentation.

i realize isn't mongodb answer, specific error ($$hashkey), due angularjs.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -