HI @vsr1,
THANKS for your reply.
the whole promotion document as follow:
[
{
"kitchen": {
"_id": "Promotion.9c35b903-4df7-493f-b7f2-816a6edd55c8",
"_rev": "2-bdbeb19ebb519ef55694fb2966be8b96",
"channelId": "733d2f51",
"className": "Promotion",
"dataType": "BaseData",
"name": "308套餐",
"owner": "733d2f51_casher",
"promotionDishList": {
"Dish.006be66f-53bf-4605-882f-52413e691e8d": {
"count": 1,
"price": 32
},
"Dish.36d6a59f-5b85-4686-9381-bfcc41636cfc": {
"count": 1,
"price": 78
},
"Dish.405673dd-7248-4e6e-ba2e-6e339143b1ea": {
"count": 1,
"price": 58
},
"Dish.45d0d8c4-b526-402f-9b26-32500ea943f4": {
"count": 1,
"price": 58
},
"Dish.4cb2a2ed-19bd-4ac7-ba85-227e4295b0fe": {
"count": 1,
"price": 28
},
"Dish.7366d6d5-a2d8-441d-9b84-14f31785ce5d": {
"count": 1,
"price": 68
},
"Dish.8f84d1e0-23ae-4166-974f-1c347d198246": {
"count": 5,
"price": 3
},
"Dish.a2422caa-1b41-4687-aadb-c339cb414635": {
"count": 1,
"price": 38
},
"Dish.f6005260-6078-4532-94de-d1476c7b3e7f": {
"count": 1,
"price": 48
}
},
"promotionRuleList": {},
"promotionType": 3
}
}
]
and the one of dishes document as follow:
[
{
"kitchen": {
"channelId": "733d2f51",
"className": "Dish",
"code26": "HZMDF",
"code9": "49633",
"kindId": "DishesKind.0f458808-5ed1-4b29-ba8d-fc4d54b1fe51",
"name": "徽州毛豆腐",
"price": 32,
"sell": false,
"sortNum": 99
}
}
]
I write a N1QL statement as follow:
SELECT pm.promotionType as type, dish.name as dishName, dish.kindId, meta(dish).id as dishId
,(SELECT raw p.val.count from OBJECT_PAIRS(pm.promotionDishList) as p
where p.name = meta(dish).id) as count
FROM kitchen AS pm
JOIN kitchen AS dish ON KEYS OBJECT_NAMES(pm.promotionDishList)
WHERE pm.className = 'Promotion'
AND meta(pm).id = "Promotion.9c35b903-4df7-493f-b7f2-816a6edd55c8"
the result is:
[
{
"count": [
1
],
"dishId": "Dish.006be66f-53bf-4605-882f-52413e691e8d",
"dishName": "徽州毛豆腐",
"kindId": "DishesKind.0f458808-5ed1-4b29-ba8d-fc4d54b1fe51",
"type": 3
},
{
"count": [
1
],
"dishId": "Dish.36d6a59f-5b85-4686-9381-bfcc41636cfc",
"dishName": "徽州三鲜锅",
"kindId": "DishesKind.0f458808-5ed1-4b29-ba8d-fc4d54b1fe51",
"type": 3
}
]
Don’t know if I wrote this correctly?
"count": [
1
],
how can I convert it to:
{
"count": 1,
"dishId": "Dish.006be66f-53bf-4605-882f-52413e691e8d",
"dishName": "徽州毛豆腐",
"kindId": "DishesKind.0f458808-5ed1-4b29-ba8d-fc4d54b1fe51",
"type": 3
}
thank you very much.
angular