Import data with relationships

Hi.

Is there anyway to import data that has relationships across collections?

I have 4 related collections - I can upload them individually - using the Data import feature but I can’t see any explanation of how the relationships between documents get imported. Is there a best practice for this?

Thanks in advance.

Currently, the import command in fauna-shell does not support relations during import. This is a known problem, but we have not yet identified a great solution.

Until we do have a solution, you would have to write your own FQL queries to import the data and maintain the relations.

Thanks Ewan.

I will have a stab at that.

Each collection has a unique identifier so I guess I could use Match and update to loop through my data?

Each collection has a unique identifier

Yes. Two collections cannot share a name, so the collection name is unique in that database. Child, peer, or parent databases might have collections with the same name though.

Match works if you have an appropriate index. If you just want to iterate through all of the documents in a collection, you can use Documents(Collection("collection_name")).

Note that the maximum number of documents per page is 100,000 (default is 64). If you have more documents than that, you’ll need to handle the relationship stitching with multiple queries.

1 Like