These are chat archives for Automattic/mongoose

11th
Mar 2016
James Lee
@uptownhr
Mar 11 2016 13:59 UTC
@ianmaddox maybe i didn't understand what "connect blocking" means. Can you explain?
Alex Shoronov
@underoot
Mar 11 2016 15:34 UTC
Hi all!
James Lee
@uptownhr
Mar 11 2016 15:34 UTC
hello
Alex Shoronov
@underoot
Mar 11 2016 15:36 UTC
@uptownhr Can You help me. It is normal behavior of mongoose that if I create schema with not required field with type, i.e. Boolean, I can set in this field null later?
James Lee
@uptownhr
Mar 11 2016 15:37 UTC
i believe so :)
Alex Shoronov
@underoot
Mar 11 2016 15:37 UTC
Why? What about type checking? :-)
James Lee
@uptownhr
Mar 11 2016 15:39 UTC
i don't think type of supposed to be checked against type
null is equivalent to not set
and you can definitely create models where it is not set
also, i don't believe it is type checking. Mongoose will attempt to cast to the type you specified
James Lee
@uptownhr
Mar 11 2016 15:45 UTC
so if schema, { test: String }
new model({test: 1})
test will become '1'
or {test: Boolean}
new model({test 'asdfasdfasdfasdf'})
test will be true
if {test: null}, then test will be null