Adding Data
In addition to an _id
key, an _action
key is always included, but typically inferred and thus optional for most operations. If we are adding data, we can include "_action": "add"
, or we can omit it, as it is inferred. Only one action can be performed per transaction.
In order to add data, you must use a temporary id, i.e. "chat"
. The temporary id is a string, and has to begin with the collection to which you are adding (for instance chat
).
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.
For example, to add a person:
[
{
"_id": "person",
"handle": "aSmith",
"fullName": "Alan Smith",
"favNums": [1, 2, 3]
}
]
// Note that favNums is a multi-cardinality predicate, so it has to be in []
If you want to create two new people, you can just put both transactions within the same [ ]
. Order of the key-value pairs does not matter.
[
{
"handle": "aGable",
"fullName": "Anna Gable",
"favNums": [28],
"_id": "person"
},
{
"_id": "person",
"fullName": "Zack Moon",
"handle": "zMoon",
"favNums": [0, -3]
}
]
Add a Person
Write a transaction
Using the above transaction examples, create your own person with all of the same predicates.