I'm new to ArangoDB but I've been using the Arango-Net-Standard driver with some success to add nodes and edges to a graph in C#.
I can create Documents in bulk using this call
await conn.Document.PostDocumentsAsync<Document>("my_document_collection", allDocuments, null)
But I can't see an obvious way of creating edges in bulk. A complicating factor is that I don't know the Document id's so have to do a lookup on a property (uuid) that I do know.
This AQL works in the web front end. But I'm not sure how to use the ArangoDB-Net-Standard driver to execute it. Should I define this as a function in the database first, and then call it using the 'Cursor' endpoints?
Note: I build up the 'data' part dynamically in the real code.
LET data = [
{
'parent': { 'from_uuid': '<parent-uuid>' },
'child': { 'to_uuid': '<child1-uuid>' }
},
{
'parent': { 'from_uuid': '<parent-uuid>' },
'child': { 'to_uuid': '<child2-uuid>' }
}
]
FOR rel in data
LET parentId = FIRST(
FOR n IN nodes
FILTER n.Properties.uuid == rel.parent.from_uuid
LIMIT 1
RETURN n._id
)
LET childId = FIRST(
FOR n IN nodes
FILTER n.Properties.uuid == rel.child.to_uuid
LIMIT 1
RETURN n._id
)
FILTER parentId != null AND childId != null
INSERT { _from: childId, _to: parentId } INTO edges
return NEW
Thanks