I have problem. I have a collection orders
. I want to get all documents and all field except the field dataOriginSystem
inside metaData
.
Is there an option to exclude this value, or make it null?
SELECT * EXCEPT(ColumnNameX, [ColumnNameY, ...])
FROM TableA
This my collection orders
:
[
{'_id': 'orders/213123',
'contactEditor': {'name': 'Max Power',
'phone': '1234567',
'email': '[email protected]'},
'contactSoldToParty': {'name': 'Max Not',
'phone': '123456789',
'email': '[email protected]'},
'isCompleteDelivery': False,
'metaData': {'dataOriginSystem': 'Goods',
'dataOriginWasCreatedTime': '10:12:12',},
'orderDate': '2021-02-22',
'orderDateBuyer': '2021-02-22',
},
{'_id': 'orders/12323',
'contactEditor': {'name': 'Max Power2',
'phone': '1234567',
'email': '[email protected]'},
'contactSoldToParty': {'name': 'Max Not',
'phone': '123456789',
'email': '[email protected]'},
'isCompleteDelivery': False,
'metaData': {'dataOriginSystem': 'Goods',
'dataOriginWasCreatedTime': '10:12:12',},
'orderDate': '2021-02-22',
'orderDateBuyer': '2021-02-22',
},
]
AQL
FOR doc IN orders RETURN doc
I want something like
FOR doc IN orders RETURN doc WITHOUT metaData_dataOriginSystem
FOR doc IN orders RETURN doc AND metaData_dataOriginSystem = NULL
So that the returned documents do not have the field metaData_dataOriginSystem
or the field should be Null
What I want (the other fields should all exist!)
[
{'_id': 'orders/213123',
...
'isCompleteDelivery': False,
'metaData': {<Removed>,
'dataOriginWasCreatedTime': '10:12:12',},
...
},
OR
{'_id': 'orders/12323',
...
'isCompleteDelivery': False,
'metaData': {'dataOriginSystem': Null,
'dataOriginWasCreatedTime': '10:12:12',},
...
},
]
Use UNSET()
or UNSET_RECURSIVE()
.
UNSET(document, attributeName1, attributeName2, ... attributeNameN) → doc
Remove the attributes attributeName1
to attributeNameN
from document. All other attributes will be preserved.
FOR doc IN orders RETURN UNSET( doc, "orderData", "dataOriginSystem")
If you want to remove a nested value, you need to Merge
FOR doc IN orders RETURN MERGE(doc, {metaData: UNSET(doc.metaData, "dataOriginSystem")})