terminusdb
terminusdb copied to clipboard
woql insert_document with reference between documents
we can not insert multi documents with reference between them
const p1 = {
"@type": "Person",
"@capture": "Id_Tom",
"name": "Tom",
"rival": { "@ref": "Id_Jerry" }
}
const p2 = {
"@type": "Person",
"@capture": "Id_Jerry",
"name": "Jerry"
}
const q = WOQL.and(WOQL.insert_document(WOQL.doc(p1)), WOQL.insert_document(WOQL.doc(p2)));
we can not insert array of documents
const p1 = [{
"@type": "Doc01",
"name": "tom"
},
{
"@type": "Doc01",
"name": "tom01"
}]
WOQL.insert_document(WOQL.doc(p1))
thank you Francesca-Bit for picking this up! My understanding is that the only work around is to use addDocument
yes, you can use addDocument like in the follow example
const json ={
"@type":"Person",
"name":"Tom",
"rival":{
"@type":"Person",
"name":"Jerry"
}
}
client.addDocument(json)