[英]Update inner object in arangodb
I have an object stored in arangodb which has additional inner objects, my current use case requires that I update just one of the elements. 我有一个存储在arangodb中的对象,该对象具有其他内部对象,我的当前用例要求仅更新元素之一。
Store Object 储存物件
{
"status": "Active",
"physicalCode": "99999",
"postalCode": "999999",
"tradingCurrency": "USD",
"taxRate": "14",
"priceVatInclusive": "No",
"type": "eCommerce",
"name": "John and Sons inc",
"description": "John and Sons inc",
"createdDate": "2015-05-25T11:04:14+0200",
"modifiedDate": "2015-05-25T11:04:14+0200",
"physicalAddress": "Corner moon and space 9 station",
"postalAddress": "PO Box 44757553",
"physicalCountry": "Mars Sector 9",
"postalCountry": "Mars Sector 9",
"createdBy": "john.doe",
"modifiedBy": "john.doe",
"users": [
{
"id": "577458630580",
"username": "john.doe"
}
],
"products": [
{
"sellingPrice": "95.00",
"inStock": "10",
"name": "School Shirt Green",
"code": "SKITO2939999995",
"warehouseId": "723468998682"
},
{
"sellingPrice": "95.00",
"inStock": "5",
"name": "School Shirt Red",
"code": "SKITO245454949495",
"warehouseId": "723468998682"
},
{
"sellingPrice": "95.00",
"inStock": "10",
"discount": "5%",
"name": "School Shirt Blue",
"code": "SKITO293949495",
"warehouseId": "723468998682"
}
]
}
I want to change just one of the products stock value 我只想更改产品库存值之一
{
"sellingPrice": "95.00",
"inStock": "10",
"discount": "5%",
"name": "School Shirt Blue",
"code": "SKITO293949495",
"warehouseId": "723468998682"
}
Like update store product stock less 1 where store id = x, something to this effect 就像更新商店产品库存减去1(商店ID = x)一样,可以达到这种效果
FOR store IN stores
FILTER store._key == "837108415472"
FOR product IN store.products
FILTER product.code == "SKITO293949495"
UPDATE product WITH { inStock: (product.inStock - 1) } IN store.products
Apart from the above possibly it makes sense to store product as a separate document in collection store_products. 除此之外,将产品作为单独的文档存储在collection store_products中可能是有意义的。 I believe in NOSQL that is the best approach to reduce document size. 我相信NOSQL是减少文档大小的最佳方法。
Found answer 找到答案
here arangodb-aql-update-single-object-in-embedded-array and there arangodb-aql-update-for-internal-field-of-object 这是arangodb-aql更新单个对象在嵌入式数组中 ,还有arangodb-aql更新对象内部的字段
I however believe it is best to maintain separate documents and rather use joins when retrieving. 但是,我认为最好是保留单独的文档,而是在检索时使用联接。 Updates easily 轻松更新
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.