MongoKitten currently has first-class support for two identifiers; ObjectId and UUID.

UUIDs are a Subtype of String, whereas ObjectId has a custom representation.

ObjectId

When editing an ObjectId, people commonly mistake it with a String. MongoDB is preferably seen as 12 bytes, 4 of which indicate the creation timestamp. The other 8 bytes are filled with (pseudo)random information.

When editing an ObjectId, it's common representation is 24 hexadecimal characters. This translates back to 12 bytes.

ObjectId fields provide a red underline when a character is missing or not hexadecimal. If an ObjectId is partially correct and committed (by for example pressing Enter), the last correctly formatted representation is used instead.

Options

Identifiers come with a couple of handy options, which are presented on right-clicks, or when clicking the icon to the right of the field.

When not editing the Document, an arrow button appears. When clicked, this button will present a window that attempts to resolve relations that match this identifier.

For example, a ChatMessage contains the field sender, which related to a User model. When you click the arrow-button, the field looks up interesting relations in other databases. In this case, it'll present you with the User model that sent the message.

Creating Relations

When editing, a couple additional options appear. The simplest one is simply to generate a random identifier.

When working with data, your relations are a common backbone of the application. MongoKitten therefore has two tools to establish a relation.

Create Relation will allow you to select a (different) collection in which a new entity is created. In the above example, you can use the 'Create Relation' button to create the user model that sent the message. The created entity's identifier is then used as the value of this field.

Find Relation allows you to select another entity within any of the collections in this database. The selected entity's identifier is then used as the value of this field.

Both buttons cases are primarily useful while developing or debugging your application.