These are chat archives for Automattic/mongoose

1st
Aug 2017
Ismail
@ismail3992
Aug 01 2017 05:39
@uptownhr Nope Mongoose provides schema-based solution
Ayush Bahuguna
@relentless-coder
Aug 01 2017 08:21
how do I prevent mongoose from adding fields to the model documents that aren't mentioned in the schema
the problem is that, the front end developers keep sending wrong fields or typos and they get saved to document. how do i prevent it from happening?
Paul "Joey" Clark
@joeytwiddle
Aug 01 2017 09:21
@relentless-coder Add the option strict: ‘throw’ to your schemas.
@relentless-coder As well as that, I make all fields required: true by default, to encourage the front-end devs to respect our schemas. ;)
@uptownhr Try it and see. Mongoose can throw an error if you query on non-existent fields, but I believe that functionality is opt-in with strictQuery: ‘throw': Automattic/mongoose#5165
Jemli Fathi
@jemliF
Aug 01 2017 10:08
Hi
Ayush Bahuguna
@relentless-coder
Aug 01 2017 10:14
@joeytwiddle :D Would strict: true work?
Paul "Joey" Clark
@joeytwiddle
Aug 01 2017 10:15
@relentless-coder strict: true will silently discard the unknown fields.
But I prefer to throw noisy errors, to inform developers when they have made a mistake.
Ayush Bahuguna
@relentless-coder
Aug 01 2017 10:20
okay, thank you @joeytwiddle
James Lee
@uptownhr
Aug 01 2017 17:48
document.remove() doesn't remove from colleciton. why?
James Lee
@uptownhr
Aug 01 2017 18:10
sorry, i'm crazy. it is removing