non-null constraint while insert

1,560 views
Skip to first unread message

Lambda Daku

unread,
May 26, 2011, 5:45:57 PM5/26/11
to mongodb-user
Hi,
I am a newbie to the mongodb. Initially, I would like to thank you for
providing the best database nosql db software to the community, it was
indeed a fun. However, while getting myself acquainted with mongodb I
didn't manage to create a "non-null" constraint on a particular json
attribute. In other words, Is it possible to prevent user/application
from entering a document with the missing attribute?

Thanks
Daku

Scott Hernandez

unread,
May 26, 2011, 5:51:12 PM5/26/11
to mongod...@googlegroups.com
Not really. These types of constraints should be enforced in the application/framework.

In mongodb there is no schema. You can create a unique index, and it will only allow on null for that field, but this is probably not what you want, and just a byproduct of a unique index.


--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


Reply all
Reply to author
Forward
0 new messages