简体   繁体   中英

How to delete nested record in Arango DB

I want to delete the latitude and longitude

{
  "property_status": "available",
  "property_address": {
    "latitude": 35.1269874,
    "longitude": 45.34897523
  }
}

As you didn't provide any context, let me show you how to do this in AQL:

FOR doc IN coll
  FILTER ... // find the right document(s)
  UPDATE MERGE(doc, { property_address: {} }) IN coll

The idea of the query is to replace the attribute value of property_address with an empty object. If that object contained additional sub-attributes apart from latitude and longitude that you want to keep, then this is not an option.

Let's assume the following document:

{
  "_key": "1234",
  "property_status": "available",
  "property_address": {
    "latitude": 35.1269874,
    "longitude": 45.34897523,
    "place": "Kalar"
  }
}

If we want to remove latitude and longitude , but not place , then you can do the following in AQL:

FOR doc IN coll
  FILTER doc._key == "1234"
  UPDATE MERGE(doc, { 
    property_address: UNSET(doc.property_address, "latitude", "longitude")
  }) IN coll

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM