Friday, 17 September 2021

ArangoDB: AQL: Delete a document by id or key

Syntax

REMOVE doc_key IN collection

 

Example

REMOVE "41687" IN users

127.0.0.1:8529@abc_org> db.users.toArray()
[ 
  { 
    "_key" : "41687", 
    "_id" : "users/41687", 
    "_rev" : "_cSA6tje---", 
    "id" : 2, 
    "firstName" : "Sowmya", 
    "lastName" : "Gurram" 
  }, 
  { 
    "_key" : "41688", 
    "_id" : "users/41688", 
    "_rev" : "_cSA6tje--A", 
    "id" : 3, 
    "firstName" : "Madhu", 
    "lastName" : "Thatha" 
  }, 
  { 
    "_key" : "41308", 
    "_id" : "users/41308", 
    "_rev" : "_cSBTpJC---", 
    "country" : "India", 
    "firstName" : "Gopi" 
  } 
]

127.0.0.1:8529@abc_org> db._query(`REMOVE "41687" IN users`)
[object ArangoQueryCursor, count: 0, cached: false, hasMore: false]

127.0.0.1:8529@abc_org> db.users.toArray()
[ 
  { 
    "_key" : "41688", 
    "_id" : "users/41688", 
    "_rev" : "_cSA6tje--A", 
    "id" : 3, 
    "firstName" : "Madhu", 
    "lastName" : "Thatha" 
  }, 
  { 
    "_key" : "41308", 
    "_id" : "users/41308", 
    "_rev" : "_cSBTpJC---", 
    "country" : "India", 
    "firstName" : "Gopi" 
  } 
]

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment