longevity

A Persistence Framework for Scala and NoSQL

View project on GitHub

mongodb translation

The persistent object is translated directly into a BSON document as described in the earlier section Persistent to JSON. Some other persistence-related fields are added to the BSON. All these fields are prefixed with an underscore (_). For this reason, we highly recommend against writing persistent objects with members whose names start with an underscore.

We add some underscore-prefixed properties to the BSON. The first is _id, as described in the next section. The second is _rowVersion, which is used by optimistic locking, and is only included when optimistic locking is turned on. We also include timestamp properties _createdTimestamp and _updatedTimestamp for diagnostic purposes, when write timestamps is turned on. More such fields may be added in the future.

MongoDB collection names are generated by uncapitalizing the camel-cased name of the persistent class.

prev: cassandra keys
up: translating persistents to the database
next: mongodb keys