Create Object Payloads
Here we will create payloads for objects of different objecttypes, as well as linking these objects together using lookups.
Simple linked objects
These objects are simple and are not linking other objects.
Orte (orte
)
orte
)This objecttype is hierarchic. Each field contains a link (_id_parent
) to reference its parent. Instead of _id_parent
, we will use lookup:_id_parent
instead. The unique field that is used for reference is name
. Apart from this, there are no other fields in this objecttype.
All user objects consist of meta-fields, and an object with the actual data under a key which must be the same as the value of _objecttype
. For importing, always use the _mask
_all_fields
.
We will create the following hierarchical structure of places:
Europa
Deutschland
Berlin
Brandenburg
There are four levels, so we need to upload the objects in four different payloads in the following order: ["Europa"]
, ["Deutschland"]
and ["Berlin", "Brandenburg"]
. So we make sure that the parent has always been imported already before it is referenced.
Payload #1
The structure for the user object payloads is always the following:
The objects have the following structure:
On top level, the _objecttype
and _mask
must be defined. The value of _objecttype
is "orte"
, so we define the object itself under the key orte
.
In orte
, the _id_parent
is null
(or it can also be not set at all), since this object is on the top level of the hierarchy and has no parent.
Every imported object must have the _version
, since it is a object that will be newly created.
The actual data "Europa" is saved under the key name
. The key is the same as the internal field name in the datamodel.
The complete first payload looks like this:
Save this payload as userobject-orte-level-0.json
and add the filename to the manifest.
For hierarchical objects it is good practice to include the hierarchy level in the payload filenames to make sure they are in the correct order.
Payload #2
Define the object that contains the name "Deutschland", which is a child of "Europa".
The complete second payload looks like this:
The parent object is referenced by the field name
in lookup:_id_parent
. The only key in this object is the field name, and the value is the value of this field in the database. This feature only works, if you know that the field is set and unique for all objects of this objecttype.
Here we tell the server to use the ID of the object with name = "Europa"
as the parent ID.
Save this payload as userobject-orte-level-1.json
and add the filename to the manifest.
Payload #3
On this level, there are two objects, that both have the same parent "Deutschland". Both can be saved in the same payload, since they are not depending on each other in any way.
The complete second payload looks like this:
Save this payload as userobject-orte-level-2.json
and add the filename to the manifest.
Personen (personen
)
personen
)This objecttype is not hierarchical, so all objects can be saved in the same payload:
Note that you can use the newline character in multiline text fields (adresse
in first object). Also you can leave any field empty, as long as it has no NOT NULL
constraint or any other check constraints that do not allow empty fields (missing key adresse
in second object).
Save this payload as userobject-personen.json
and add the filename to the manifest.
Schlagwörter (schlagwoerter
)
schlagwoerter
)This objecttype is not hierarchical, so all objects can be saved in the same payload:
Save this payload as userobject-schlagwoerter.json
and add the filename to the manifest.
Main objects
Here we create the payloads for the more complex main objects (objects that can be found in the main search). These objects can have assets, tags, pools, links to the other simple objects we created before, and have links to eachother.
Bilder (bilder
)
bilder
)This objecttype is used to save images as well as additional information about the time and place the picture was taken, and who was the photographer.
We create an object that saves this image from unsplash.com:
Fields that are set in the object:
pool
The pool must be specified for all objects with pool management. We want to add the new objects to the pool "Migrated Objects" by referencing the pool reference
instead of the _id
:
reference
To be later able to reference this object, use the field reference
to set a unique value. Other than for basetypes, this field is part of the schema and must be included in the datamodel. Set the reference to "bild_01", so later you can use a lookup to link to this object in a objekte
object:
titel
This is a multi language field, so under the key, there is an object with language codes and the translations for each language. Here we set the title for german and english:
datei
(asset)
The image is saved in the asset field datei
in the object. During the import, the images must be hosted and are loaded over HTTP(S). You can save the images in the same server where the payloads are stored, and use the server url, or use an image from any other HTTP server.
To tell the JSON Importer which file should be uploaded to the EAS and linked in the object, you have to specify the URL of the file. The Importer will load the file from the URL and upload it. So, replace _id
with eas:url
:
There must always be one asset that is set as "preferred": true
To specify a filename that overwrites the filename that is associated with the URL, especially if it does not contain an actual filename, use the optional key eas:filename
. This filename will be passed to the EAS during file upload.
aufnahmedatum
(date field)
This is a date field, so under the key, there is an object with the value
and the date representation in YYYY-MM-DD
format:
aufnahmeort
(link to objecttype orte
)
This is a link to another object. Instead of linking it using the _id
, the object is referenced in a lookup by the unique field name
(the same as in the hierarchical lookup for the parent ID):
This creates a link to the orte
object with the name
"Berlin".
personen.person
(links in nested table to objecttype personen
)
There are multiple links to objects of type personen
inside a nested table. The nested table personen
has the fields bemerkung
and person
. The field for the nested table in the datamodel consists of the prefix nested:
, the objecttype name and the name of the nested table: "_nested:bilder__personen"
.
bemerkung
is a free text field, person
is the link to the personen
object.
Instead of linking it using the _id
, the object is referenced in a lookup by the unique field name
:
Each element in the array "_nested:bilder__personen"
represents a row in the nested table. In this example, we will add one row to the nested table, which contains the link to person
"Max Mustermann", and the bemerkung
field "Fotograf".
Combined, the entry for the linked object in the nested table, looks like this:
schlagwoerter.schlagwort
(links in nested table to objecttype schlagwoerter
)
There are multiple links to objects of type schlagwoerter
inside a nested table. schlagwort
is the link to the schlagwoerter
object.
Instead of linking it using the _id
, the object is referenced in a lookup by the unique field name
:
A second object in the nested table can be added by referencing the second object by the name
"Panorama".
Combined, the entry for the linked objects in the nested table, looks like this:
Complete Payload
The complete payload for the bilder object(s) looks like this:
Save this payload as userobject-bilder-0.json
and add the filename to the manifest.
Objekte (objekte
)
objekte
)This is the other main object. It has pool management, and can have tags.
Fields that are set in the object:
pool
Add the new object to the pool "Migrated Objects" by referencing the pool reference
instead of the _id
.
tags
Tags are set in an array next the object, at the top level key _tags
. Each object in the array is one tag. Instead of using the tag ID, reference the tag "Public Access" by using the lookup for the reference "public":
inventarnummer
This is a simple text field, the value can be assigned directly.
datierung
(date range field)
This is a date range field, so under the key, there is an object with the start date (from
) and the end date (to
). Both values contain the date representation in YYYY-MM-DD
format:
Complete Payload
The complete payload for the bilder object(s) looks like this:
Save this payload as userobject-objekte-0.json
and add the filename to the manifest.
Reverse linking of bilder
in objekte
bilder
in objekte
The objecttype objekte
contains a reverse editable link to the objecttype bilder
. This means, in the JSON there is nested table where multiple bilder
objects can be linked. These linked objects can be edited directly in the objekte
object which contains them. Escpecially, this means they can be created inline. By adding a bilder
object inside the reverse linked table in the payload for a new objekte
object, you can create multiple objects at the same time.
We create an object that saves this image from unsplash.com inside its internal bilder
object.
Add the bilder
object, including the eas:url
and other fields, directly in the reverse nested table _reverse_nested:bilder:objekte
. This nested table can include multiple bilder
objects, that link back to this object, and can be directly edited inside this object.
The bilder
and objekte
objects both need a lookup to the pool, and the top level object has a lookup for the tag.
Complete Payload
The complete payload for the bilder object(s) looks like this:
Save this payload as userobject-objekte-1.json
and add the filename to the manifest.
Last updated