多くのレコードを持つ 3 つのコレクションがあります。それらのそれぞれには、価格、名前などのいくつかのキーがあります...
c
ご覧のとおり、他のコレクションとは異なり、コレクションに提出された価格はdata.detail
フィールドにあります。
に基づいて、そこにあるコレクションの価格の平均を計算したいと考えていname
ます。
最終結果は、計算された価格の製品の配列になるはずです。出来ますか?
collection a = [
{"id":1, "price": "1200", "name": "x1"},
{"id":2, "price": "2000", "name": "x2"},
{"id":3, "price": "3000", "name": "x3"},
...
]
collection b = [
{"id":1, "price": "1500", "name": "x1"},
{"id":2, "price": "2500", "name": "x2"},
{"id":3, "price": "3125", "name": "x3"},
...
]
collection c = [
{"id":1, "data": {"detail": {"price": 1900}}, "name": "x1"},
{"id":2, "data": {"detail": {"price": 2900}}, "name": "x2"},
{"id":3, "data": {"detail": {"price": 3500}}, "name": "x3"},
...
]
私はこれを結果として持ちたい:
$result = [
{"id":1, "price": "1533.3", "name": "x1"},
{"id":2, "price": "2466.6", "name": "x2"},
{"id":2, "price": "3208.3", "name": "x3"},
...
]