Moved from GitHub dgraph/2848
Posted by MichelDiz:
What you wanted to do
Import JSON data made by any other DB but having sure that the nodes will be unique.
Informing Bulkload what are the Keys of my JSON are that represent uniqueness.
And also be able to setup a direct injection from API’s serving JSON.
something like this for locally JSON
dgraph bulk --jsons="./json.json" --setunique="mission_name, rocket_id, payload_id, site_id"
That way Bulkload would generate a “uid” key throughout JSON before sending it to Dgraph. This ensures that objects are unique.
Also, it would be interesting to have an option to import JSON offered by API. This can help a lot in other situations. Like in Database Migration. Lots of people could use this to migrate from old DBs to Dgraph.
From API’s serving JSON:
dgraph bulk --bulkapi="https://api.spacexdata.com/v3/launches/, https://api.spacexdata.com/v1/nasa_launches/" --setunique="mission_name, rocket_id, payload_id, site_id"
Any external references to support your case
e.g: I have this API https://api.spacexdata.com/v3/launches/ . It provides me with a dataset. However, since there is no “uid: _:blank” key (with a blank node) all the rockets in this object of this API will not be unique in Dgraph when I import it.
This was discussed with @codexnull