These are chat archives for Automattic/mongoose

26th
Aug 2015
shotokai
@shotokai
Aug 26 2015 21:56
new to mongoose. Struggling to figure out how to elegantly remove referenced docs when updating the parent. Example is I have a model 'Purchase', which references 'Asset'. Asset belongsTo Purchase. When I save a Purchase, if an Asset is not in the Purchase.assets[], but Asset.purchase_id === purchase._id, I want to remove the Asset from the collection. is there a method for this or a pattern for setting this up?