When passing data into a local database, you need to represent links in the JSON. The process of converting this into a node to which the row will link is known as link resolution.
In the simple case, a link is passed in as an object which includes a reference. The reference identifies the node, making link resolution simple. For example, if you wanted to specify a range for a product in a put operation, you might pass something like this.
{
"range": {
"reference": "acme.sales.database.range.toys"
}
}
It does not matter if you also pass the name and url or other fields, but only the reference will be used if it is present.
You can also pass the reference by itself, not in an object. So the following is equivalent.
{
"range": "acme.sales.database.range.toys"
}
If you don't have the node reference, you can pass the key fields instead, inside an object. If the key field was range_id, you could pass something like this.
{
"range": {
"range_id": "toys"
}
}
Files
Files are links, and you can identify a file using a reference field, just like a normal link.
A copy of the file node is taken which uses the row as a folder. So when you pass a reference, the local database will take a copy of that node and then hold a link to the copy.
Files can also be passed in using other ways:
- Using the string created by the file upload functionality which identifies a newly uploaded file.
- Using the JSON equivalent of the upload string (used by the OmniLink).
- Using a FILE_INFO structure used by the worker process functionality.
- Retrieved from the url property of the object.
File resolution uses the rules described in the from() method of the File Node Script.