These are chat archives for Automattic/mongoose

11th
Jun 2016
James Lee
@uptownhr
Jun 11 2016 06:40
@vkarpov15 what is your fav?
Khaled Mohamed
@KhaledMohamedP
Jun 11 2016 21:55

Quick question: Removing the parent doesn't remove it's children

ParentSchema = ...{
  children: [[{type: Schema.ObjectId, ref: 'Child'}]]
}
// Now when I remove the parent, the children are not remove 
// The same applies to children if they are remove the parent still has the ID reference to the removed children

Can someone point what's the best approach to resolve such a problem without adding complexity to the code.

Valeri Karpov
@vkarpov15
Jun 11 2016 23:25
@LeonineKing1199 def mongoose. Mongoose models are very complex objects - generally, if you want to use something like ramda or lodash, you should probably .toObject() first
@uptownhr I just use express+co for everything these days. Would like to use koa except for then I'd have to learn to think in koa, and I tend to prefer the devil I know to the devil I don't :)
but TBH now that es6 is out, I really don't care which framework I use so long as it has generators and I can use co
current rule of thumb is keep business logic out of framework now that co solves callback soup
@KhaledMohamedP expected behavior, mongoose won't do that for you. You can write a post('remove') hook for that