Optional: Update links between Objects
In some cases, it might be necessary to update objects during the migration process, for example if there are links to objects that did not exist yet at the time of the first import. In this case, it is possible to update existing objects by using lookups for the object ID, and incrementing the object version.
In this example, we want to link the first bilder
object we created (with the reference "bild_01") to the first objekte
object with the inventarnummer
"987654321". For referencing the objects, we can use lookups for the IDs with fields that we know are unique and not empty in the existing objects. The direct link between these objects is from the bilder
object to the objekte
object, in contrast to the reverse nested link in the examples before.
Make sure to include all values in the update of the object, that you want to save in the object. Since the server would delete all values that are not set, they need to be inlcuded.
The latest version of any imported object will define all values in the object.
Lookup for object ID
To reference the object for the update, instead of specifying the _id
(which was not inlcuded in the first version), use a lookup for the reference "bild_01", which was set in the first object version:
Incremented version
The version can be specified directly, so you can set "_version": 2
, if you know that this is the first update. For every update, the version must be exactly one more than the current version. Otherwise, this will cause an error.
If you do not want to keep track of object versions, you can use the JSON Importer feature which will care for setting the correct version: replace "_version": 2
with
Link to the objekte
object
objekte
objectFrom the perspective of the objekte
object, the reverse nested link has the structure of a nested table, since one objekte
object can be referenced by multiple bilder
objects.
On the other hand, any bilder
object can only have one link to one objekte
object. So from the perspective of bilder
, it is a normal link to an objekte
object. We know that the unique field in the objekte
object is inventarnummer
, and the value we specified is "987654321". So the lookup in the link is the following:
Complete Payload
The complete payload for the bilder object(s) looks like this:
Save this payload as userobject-bilder-0-version-2.json
and add the filename to the manifest.
Last updated