Skip to main content

Adding Data

In order to add data, you must use a temporary id, i.e. "chat$1". In this case, "_action": "add" is inferred. Any predicates that you wish to add to this subject should be included as key-value pairs.

The keys can contain the full predicate name including the namespace, i.e. chat/message or you can leave off the namespace if it is the same as the collection the subject is within. i.e. when the subject is within the chat collection, just message can be used which is translated to chat/message by Fluree.

[
{
"_id": "person",
"handle": "oRamirez",
"fullName": "Oscar Ramirez"
},
{
"_id": "person",
"handle": "cStuart",
"fullName": "Chana Stuart"
}
]

Nested Transactions

If you are updating or creating a new subject, for example a new chat and that chat contains a reference to a new subject, such as the chat/person, then you can use two transactions: one to create the chat, and the second to create the person.

FlureeQL example:

[
{
"_id": "chat",
"message": "This is my first comment ever! So smart.",
"person": "person$alana",
"instant": "#(now)"
},
{
"_id": "person$alana",
"handle": "adean",
"fullName": "Alana Dean"
}
]

Alternatively, you can nest transactions by simply declaring the new person directly within the chat transaction.

FlureeQL example:

[
{
"_id": "chat",
"message": "I have something to say!",
"person": {
"_id": "person$bBolton",
"handle": "bbolton",
"fullName": "Bob Bolton"
},
"instant": "#(now)"
}
]