These are chat archives for Automattic/mongoose

12th
Jun 2016
Khaled Mohamed
@KhaledMohamedP
Jun 12 2016 00:03
@vkarpov15 thanks for the quick reply, is there way to delete all of the children array using mongoose? or should I loop through the entire array and delete each one separately
James Lee
@uptownhr
Jun 12 2016 00:53
@vkarpov15 agreed. I recently switched to koa and there was big overhead of switcthing over all the middlewares i was used to in express
some i even had to rewrite
yea co is amazing as well. didn't realize i could use it without koa until i just tried it :)
i'm back to using express as well
i' not usre if there are any more main differences, but i think the main offering of koa is,
  1. generators without co
  2. ctx that holds req and res
  3. middleware that comes back (not sure how to word this)
Valeri Karpov
@vkarpov15
Jun 12 2016 01:30
@KhaledMohamedP you can delete them all using a single remove query and $in
Ah you're using koa 2? Sweet. Yeah my deal right now is that I implement business logic as pure functions using co, and then wrap those calls in express so they're one liners. Framework free is the way to go, especially since right now I'm wrestling to get my company's code off of freaking loopback
Khaled Mohamed
@KhaledMohamedP
Jun 12 2016 02:37
@vkarpov15 thanks for the tip
reza-farhadian
@reza-farhadian
Jun 12 2016 02:55
Hello guys, i have question
Is it safe to use URL queries for Model.find() conditions? like '/events/?condition={"price": { "$lte": 20 }}'

@vkarpov15

Is it safe to use URL queries for Model.find() conditions? like '/events/?condition={"price": { "$lte": 20 }}'

Valeri Karpov
@vkarpov15
Jun 12 2016 03:52
Depends, it can have unintended consequences, check out mongo
Mongo-sanitize on npm for more details
reza-farhadian
@reza-farhadian
Jun 12 2016 05:23
@vkarpov15 Thanks for help.
LeonineKing1199
@LeonineKing1199
Jun 12 2016 22:49

@vkarpov15

@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

Yeah, we sort of discovered that the hard way :P

My question is, is that documented anywhere? This feels like something that should be pretty up front and I'm not recalling off-hand ever seeing it directly.