Meteor collection2 field in $unset list -
i have simpleschema:
imageurl: { type: object, optional: true, autovalue: function() { if (meteor.isclient) return; var imagefield = this.field('imageid'); if (!imagefield.isset){ this.unset(); } else { var imageobj = mealsimages.findone(imagefield.value); if (imageobj){ return {thumb: imageobj.s3url('thumb'), big: imageobj.s3url('big')}; } } }, autoform: { label: false, type: 'hidden', affieldinput: { type: "hidden" } } },
for reason, when update record field appears in $unset array:
meteor.methods({ mealupsert: function(doc, mealid) { check(doc, meals.simpleschema()); console.log('test7'); console.log(doc); if (mealid){ meals.update({_id: mealid}, doc); } else { mealid = meals.insert(doc); } return false; } });
will print:
i20150830-21:49:39.560(-4)? { '$set': ... i20150830-21:49:39.562(-4)? '$unset': i20150830-21:49:39.562(-4)? { imageurl: '', ...
i'm using autoform:
<template name="mealupdateform"> <div class="meal-content"> {{> quickform collection="meals" doc=this id="mealupdateform" meteormethod="mealupsert" type="method-update"}} </div> </template>
and never updated or set. clue why field appear in $unset
list?
i think i've figured out - have this.unset()
in autovalue
imageurl. called whenever omit imageid modifier, if present in document modifying!
Comments
Post a Comment