These are chat archives for Automattic/mongoose

6th
May 2015
Sérgio Marcelino
@sergiofilhowz
May 06 2015 00:10
Does anyone know a way to use bluebird Promises instead of built in mongoose Promises?
Ross
@mcky
May 06 2015 11:27
Other than recursively saving - what's the best way to save nested JSON arrays into schemas with parent/child refs?
eg { stakeholders:[ .. {outcomes:[ {.. indicators: [ {..} ] } ] } ] } -> { outcome: indicators:[{ref}], parent: {ref}}
Valeri Karpov
@vkarpov15
May 06 2015 13:35
@sergiofilhowz planning on introducing that in 4.1: Automattic/mongoose#2688
@mcky I don't quite understand, can you clarify?
Ross
@mcky
May 06 2015 13:37
sorry - i've got a load of json from the front end with nested arrays (stakeholder has many outcomes, outcomes have many indicators) - but the schemas in mongoose are all using object refs instead
at the moment it's saved using nested async forEach functions
Valeri Karpov
@vkarpov15
May 06 2015 14:59
still not quite getting the issue. One thing that may be useful is that mongoose always only saves 1 document per save() call, there's no way to translate one save() in mongoose into multiple inserts / updates on the mongodb side
Benoit Desemberg
@bdesemb
May 06 2015 15:29
Ross
@mcky
May 06 2015 15:52
Hmm - maybe a gist would be more helpful @vkarpov15 ?
Valeri Karpov
@vkarpov15
May 06 2015 17:07
@mcky yep. Open up an issue with a gist please - it's usually easier to just write the code than to write prose describing the code
@bdesemb looks like there's a reasonable answer on the SO
Ross
@mcky
May 06 2015 17:09
Will do cheers
Sérgio Marcelino
@sergiofilhowz
May 06 2015 17:15
@vkarpov15 do you wanna help with that?
Ross
@mcky
May 06 2015 17:38
saintedlama/passport-local-mongoose#74
Valeri Karpov
@vkarpov15
May 06 2015 18:13
@sergiofilhowz do I want help with ticket #2688? Yep :)
Sérgio Marcelino
@sergiofilhowz
May 06 2015 18:14
@vkarpov15 has anyone started this feature yet?
@vkarpov15 it's very important to me because my entire application use bluebird interface and they aren't compatible (bluebird has .catch function and mpromise uses .then(null, function(err){}) , everytime I use mongoose in my app I have to wrap it in a bluebird Promise and it's ugly).