假设我有这个对象:
{town_id: 13, houses_data: [
{house_id: 5, price: 32, description: "thats a house"},
{house_id: 2, price: 12, description: "thats a house"}
]
}
我想更新id为5的房子,以及#34; <&b>出售&#34;
{town_id: 13, houses_data: [
{house_id: 5, price: 32, description: "sold"},
{house_id: 2, price: 12, description: "thats a house"}
]
}
我尝试了什么:
town1 = town.findOne({town_id: 13});
获取houses_data:
twon1.houses_data
并尝试仅更新house_data
id = 5
twon1.houses_data.find({house_id: 5}).update(description: "sold");
但是我收到此错误消息:
[object Object],[object Object] has no method 'find'
我错了什么?感谢