Can I define a schema in mongodb that requires certain attributes. Very similar to NOT NULL in SQL. If possible. What is the syntax for this?
I am using node.js and mongoose. mongoose v3.6.15 mongodb v2.4.5
Edit The answer provided by Charles A is correct, but looking through the documentation, I found that in the mongoose you can also define the field as required to write off the circuit as follows:
foo : { bar : { type : String, required : true } }
mongodb mongoose
Ludwig magnusson
source share