News for hackers. Stuff that matters.
Re:Introducing MongoMallard: A fast ORM based on MongoEngine by aidos on Tuesday July 02, 2013 @01:59PM (#5979611)
I used Mongo in Python for a couple of projects recently. I tried out every single library I could find. In the end I settled on using Schematics [1] with a very thin data layer for loading and saving the objects. It worked really well. You get to work with sane Python objects and it's really easy to move between Mongo and Python.

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

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.

Re:Introducing MongoMallard: A fast ORM based on MongoEngine by rozza on Tuesday July 02, 2013 @04:30PM (#5980534)
Schematics was an early fork of MongoEngine - focusing on data modelling and validation of various data formats, dicts, json & bson documents.
Re:Introducing MongoMallard: A fast ORM based on MongoEngine by aidos on Tuesday July 02, 2013 @07:37PM (#5981431)
Interesting. I know it's a rework of DictShield but I was unaware that came from MongoEngine.
Re:Introducing MongoMallard: A fast ORM based on MongoEngine by rozza on Tuesday July 02, 2013 @02:01PM (#5979621)
Really pleased to have these improvements and look forward to getting them into MongoEngine 0.9 :)
Re:Introducing MongoMallard: A fast ORM based on MongoEngine by ddorian43 on Tuesday July 02, 2013 @01:59PM (#5979615)
What a nice layout without a hundred different analytics scripts/widgets/gadgets. Even inline css.
Re:Introducing MongoMallard: A fast ORM based on MongoEngine by thomas-st on Tuesday July 02, 2013 @02:06PM (#5979658)
Thanks Dorian, we write our posts in Markdown and use simple static content generation: https://github.com/elasticsales/hack.close.io
Re:Introducing MongoMallard: A fast ORM based on MongoEngine by ddorian43 on Tuesday July 02, 2013 @02:08PM (#5979668)
Have you been working for too long with the new ReferenceField? Because it was an issue before the 0.8 release that you could worked too. Also what version of flask-mongoengine are you using?

Also since the site doesn't have comments include a link to this page in the end?

Re:Introducing MongoMallard: A fast ORM based on MongoEngine by thomas-st on Tuesday July 02, 2013 @02:25PM (#5979778)
The thing that changed in 0.8 is that references are now stored as ObjectIds only instead of storing both the table name and the ObjectId (you can still get the old behavior by using dbref=True). However, you would still have to check whether or not the reference was an ObjectId to tell if it was valid.

We're using our fork of https://github.com/elasticsales/flask-mongoengine/ (which I admit is based on a flask-mongoengine version that is a little bit outdated).

Also, will add a link to the comments.

Re:Introducing MongoMallard: A fast ORM based on MongoEngine by skrebbel on Tuesday July 02, 2013 @02:34PM (#5979843)
Almost entirely off topic, but is "ORM" a fitting term for something that maps documents, and not relations, to objects?
Re:Introducing MongoMallard: A fast ORM based on MongoEngine by rozza on Tuesday July 02, 2013 @04:37PM (#5980570)
MongoEngine prefers ODM but documents often have relationships.

That comes at some cost in MongoDB and document databases in general. Often it is best to start with the opposite of modelling a relational db - start denormalised and normalise where it makes sense to.

The catch with MongoEngine is know that ReferenceFields are dereferenced in the application layer and design your Documents accordingly.

Re:Introducing MongoMallard: A fast ORM based on MongoEngine by hendzen on Tuesday July 02, 2013 @03:51PM (#5980311)
I've heard the term ODM used for this purpose [0].

[0] - https://github.com/jmkgreen/morphia

Re:Introducing MongoMallard: A fast ORM based on MongoEngine by dragonwriter on Tuesday July 02, 2013 @02:38PM (#5979866)
No, clearly, its not, since its not object-relational mapping.

And one of the selling points of NoSQL "document store"-style solutions is that, as they do not use the relational model, your data layout can more closely follow object construction and not need the kind of object-(datastore)-mapping represented by ORM, anyway.