mongodb - Meteor 1.0 - MinimongoError: can't append to array using string field name [-1] -
mongodb - Meteor 1.0 - MinimongoError: can't append to array using string field name [-1] -
meteor 1.0 built mongodb v2.4, doesn't have $position api introduced in mongo 2.6. therefore, i'm unable add array item(s) origin of mongodb array such:
{ $push: { <field>: { $each: [ <value1>, <value2>, ... ], $position: 0 } } }
i've tried adding items front end of mongodb array via workaround...
collectionname.update( {_id: 'xjfb2bbsyj2mafu'}, {$set: {'field.-1': data} } );
... works on server-side code , cannot interpreted minimongo:
i20141109-23:32:42.382(-5)? error in oplog callback minimongoerror: can't append array using string field name [-1] i20141109-23:32:42.382(-5)? @ minimongoerror (packages/minimongo/minimongo.js:53) i20141109-23:32:42.383(-5)? @ findmodtarget (packages/minimongo/modify.js:133) i20141109-23:32:42.383(-5)? @ packages/minimongo/modify.js:56 i20141109-23:32:42.383(-5)? @ function._.each._.foreach (packages/underscore/underscore.js:113) i20141109-23:32:42.383(-5)? @ packages/minimongo/modify.js:43 i20141109-23:32:42.383(-5)? @ function._.each._.foreach (packages/underscore/underscore.js:113) i20141109-23:32:42.383(-5)? @ function.localcollection._modify (packages/minimongo/modify.js:36) i20141109-23:32:42.383(-5)? @ packages/mongo/oplog_observe_driver.js:597 i20141109-23:32:42.384(-5)? @ object.meteor._noyieldsallowed (packages/meteor/fiber_helpers.js:11) i20141109-23:32:42.384(-5)? @ _.extend._handleoplogentrysteadyorfetching (packages/mongo/oplog_observe_driver.js:545)
what workaround exists add together items origin of mongodb array compatible meteor 1.0 / minimongo?
do need atomicity? if not, modify $set
entire array.
var doc = collectionname.findone(); doc.arr.unshift('newelement'); collectionname.update(doc._id, {$set: {'arr': doc.arr}});
otherwise, sounds you'll need in server-side code now.
mongodb meteor minimongo
Comments
Post a Comment