terminusdb icon indicating copy to clipboard operation
terminusdb copied to clipboard

woql insert_document with reference between documents

Open Francesca-Bit opened this issue 3 years ago • 2 comments

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))
 

Francesca-Bit avatar Sep 01 '22 12:09 Francesca-Bit

thank you Francesca-Bit for picking this up! My understanding is that the only work around is to use addDocument

wcoolidge avatar Sep 01 '22 14:09 wcoolidge

yes, you can use addDocument like in the follow example

const json ={
   "@type":"Person",
   "name":"Tom",
   "rival":{
      "@type":"Person",
      "name":"Jerry"
   }
}
client.addDocument(json) 

Francesca-Bit avatar Sep 02 '22 08:09 Francesca-Bit