Thursday, 2 September 2021

ArangoDB: AQL: Insert a document

Syntax

INSERT document INTO collectionName;

 

Example

var queryToExecute = `INSERT {
    "id": 123,
    "firstName" : "Krishna",
    "lastName" : "Gurram",
    "age": 33
} INTO person`

db._query(query)

127.0.0.1:8529@abc_org> var queryToExecute = `INSERT {
...>     "id": 123,
...>     "firstName" : "Krishna",
...>     "lastName" : "Gurram",
...>     "age": 33
...> } INTO person`

127.0.0.1:8529@abc_org> db._query(queryToExecute)
[object ArangoQueryCursor, count: 0, cached: false, hasMore: false]

 

Let’s query person collection.

127.0.0.1:8529@abc_org> db.person.toArray()
[ 
  { 
    "_key" : "39652", 
    "_id" : "person/39652", 
    "_rev" : "_cSAMnsi---", 
    "id" : 123, 
    "firstName" : "Krishna", 
    "lastName" : "Gurram", 
    "age" : 33 
  } 
]

 



Previous                                                    Next                                                    Home

No comments:

Post a Comment