3 ms·
Well, it depends on your application requirements. And, remember that MongoDB itself is schemaless, so any schema validation must happen at the application lay
by smlacy 16y ago
Well, it depends on your application requirements.
And, remember that MongoDB itself is schemaless, so any schema validation must happen at the application layer, and thus, is always going to be "soft". For example, just because you declare a field to be an Integer in your application layer, it doesn't mean it's actually going to be an integer when you read an object. (Especially if objects are coming in through other external data sources.)
One great use case for schema-less design would be a User object where you wanted to store arbitrary credentials and external profiles from sites like Facebook, Twitter, etc. If you were using an enforced Schema, then you have to re-create the schema from all the external sites you're using, and every time there's a change in any one of those sites you need to "upgrade" your database to include these new fields. It's really pain.