Re:Introducing MongoMallard: A fast ORM based on MongoEngine
by thomas-st on Tuesday July 02, 2013 @02:19PM
(#5979743)
Regarding schematics: We actually developed a object validation library that's very similar to it. It's called cleancat. It comes with some MongoEngine-specific fields to validate references. It's best to look at the unit tests to see how it works: https://github.com/elasticsales/cleancat/blob/master/tests/_...
Regarding collections and embeddeded documents: Yes, a lot of times it makes sense to split things out into separate collections instead of embedding them so you don't run into problems later. One nice thing about MongoEngine and MongoMallard is that they update only fields that have changed. So if you have a ListField(EmbeddedDocumentField()) and change one of the embedded documents, only that document gets sent in the update statement, which speeds things up. And yes, I wish MongoDB had better ways to ensure data integrity.
Ultimately, two projects later I'm just not happy with Mongo as a data store. I've found that the restrictions of a relational data model mean that you don't end up paralysed worrying about how to store your data. In Mongo I was forever tossing up between embedding data or splitting it up into a separate collection. And it's a choice that may well bite you later. Also, only ensuring the integrity of your data within the application is not a great idea.
[1] https://github.com/j2labs/schematics