Can I Store the JavaScript Map Object in Meteor's MongoDB? -
i have following code:
mymapfield = new map(); (var = stuff.length; i--; ) { mymapfield.set(stuff.id, { name: stuff.name, type: types.my_type }); } meteor.users.update(meteor.userid(), { $set: { 'profile.mymapfield': mymapfield } });
it doesn't work , error message doesn't ("undefined").
is there way store javascript map object in meteor's mongodb?
i don't think there direct way insert map object mongodb of now. possible workaround can suggest :
- iterate on map object, and
- store key-value pairs separately in db
the schema might this:
{ _id: someid, map: [{ key: key1, value: value1 },{ key: key2, value: value2 },{ key: key3, value: value3 },{ key: key4, value: value4 },{ ... }] }
helper functions convert map objects format , vice-versa have written effect.
Comments
Post a Comment