These are chat archives for Automattic/mongoose

12th
Nov 2015
bnord01
@bnord01
Nov 12 2015 10:39
Hi mongoose experts, is there a way to automatically convert "null" values to 0 for all Number typed keys?
bnord01
@bnord01
Nov 12 2015 10:44
Upon reading in data that is. I made a model for documents from a third party application where some 0 values are represented as "null". I was hoping for some kind like write hook where I can add a custom conversion like there exists from "0" to 0 already.
bnord01
@bnord01
Nov 12 2015 11:11
This message was deleted
bnord01
@bnord01
Nov 12 2015 11:19
Solved, found the set option.
Cade Ward
@cadebward
Nov 12 2015 17:49
Hey guys. Quick question: Can you modify a query in a pre hook? As in, insert into the query {foo: 'bar'} so that find({}) becomes find({foo: 'bar'}) before it goes to mongo.
Cade Ward
@cadebward
Nov 12 2015 18:57
Ah, its inside of the pre hook: this.find({foo: 'bar'})
That feels like its overriding it, but its just adding onto the query... i guess :)