These are chat archives for Automattic/mongoose

28th
Jun 2016
Emanuele DelBono
@emadb
Jun 28 2016 15:04
Hi. I have a collection on Mongo with several fields that are not defined in the mongoose schema. But when I query the collection, the mongoose model contains also this additional fields. Is there a way to tell mongoose to ignore them without manually remove them (for example overriding toJson)? thx
Alex Shpak
@ishikawayoshi
Jun 28 2016 16:42
@emadb Hi
I find a solution on SO http://stackoverflow.com/a/17063594 did you try this way? Unfortunately i'm not check it yourself yet.
Alex Shpak
@ishikawayoshi
Jun 28 2016 18:52
Can you give me advice do i need add mongoose.disconnect in express app or how to properly handle disconnect in mongoose?
Emanuele DelBono
@emadb
Jun 28 2016 19:14
@ishikawayoshi thx. I knew about the override of toJson but I'm searching for some settings that automatically exclude non-mapped fields. Otherwise why should I bother to define the schemas?