Temporary Ids
As mentioned in the previous lesson, a tempid can simply be the collection name, i.e. _user
.
However, if you would like to reference that tempid somewhere else in your transaction, it is necessary to create a unique tempid. To make a unique tempid, just append the collection with any non-valid collection character (anything other than a-z
, A-Z
, 0-9
, _
) followed by anything else. For example, _user$jdoe
or _user#1
.
In the below example, we are creating both a person and a chat message. We are using the person's tempid as a reference in chat/person
.
[
{
"_id": "person$joy",
"handle": "jTan",
"fullName": "Joy Tan"
},
{
"_id": "chat",
"message": "This is a message from Joy!",
"instant": "#(now)",
"person": "person$joy"
}
]
Add a Person and a Chat
Write a transaction!
Using the above transaction example, create your own person and chat, and reference that person as `chat/person`.