gpt4 book ai didi

arangodb - 更新 arangodb 中的内部对象

转载 作者:行者123 更新时间:2023-12-02 21:46:01 34 4
gpt4 key购买 nike

我有一个存储在 arangodb 中的对象,该对象具有其他内部对象,我当前的用例要求我仅更新其中一个元素。

存储对象

{
"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"
}
]
}

我只想更改其中一种产品的库存值(value)

{
"sellingPrice": "95.00",
"inStock": "10",
"discount": "5%",
"name": "School Shirt Blue",
"code": "SKITO293949495",
"warehouseId": "723468998682"
}

例如更新商店产品库存减少 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

除了上述内容之外,将产品作为单独的文档存储在集合 store_products 中可能是有意义的。我相信 NOSQL 是减少文档大小的最佳方法。

最佳答案

找到答案

这里arangodb-aql-update-single-object-in-embedded-array在那里 arangodb-aql-update-for-internal-field-of-object

但是,我认为最好维护单独的文档,而在检索时使用联接。轻松更新

关于arangodb - 更新 arangodb 中的内部对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30482859/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com