Misc stuff about Voyage and MongoDB
Written on May 28 2012.
This blog post was written a long time ago and may not reflect my current opinion or might be technically out of date. Read with a grain of salt.
Magritte is not necessary for the basic scenarios. Voyage is smart enough to infer the types of your instance variables and can serialize them. You don’t need to describe everything like you would do when building an UI with Magritte.
The Magritte descriptions are only needed when you want to override the defaults of want to have a one-to-many relationships.
In the future, it will be able to infer the to-many relations automatically but at the moment you still have to tell voyage how to deal with them.
attributeName: 'myInstVar'; "Acts on this inst var"
kindCollection: Set; "Set instead an OrderedCollection"
beLazy; "I want that references to be retrieved lazily"
VOMongoRelationDescription and its subclasses to see what is possible.
As we've seen previously, it is pretty easy to map a relation. In our example, we declared both
MQPilot as persistent by implementing
isPersistent on the class side.
isPersistent method has an unfortunate name. It actually means that a collection with the name of the class will be created in the database. If we hadn’t declared
MQPilot persistent, it would have been completely embedded in the spaceship.
Ignore instance variable
Sometimes you do not want to serialize all your instance variables. In such cases, add a
VOMongoTransientDescription like this:
puppies instance variable will be ignored by the serializer and won’t be stored in Mongo.
That’s all for today. Once again, huge thanks to Esteban for this super nice library!