I am using Mongoose with Typescript; my current document look likes this:
{
_id: 1,
id: "a",
markets: [{
type: "car",
price: 10000},
{type: "toy",
price: 10},...]
}
{
_id: 2,
id: "b",
markets: [{
type: "car1",
price: 1023400},
{type: "toy1",
price: 1032},...]
}
{
_id: 3,
id: "c",
markets: [{
type: "car2",
price: 10000},
{type: "toy2",
price: 1023},...]
}
I want to update particular {type: "car", price: 10000}
this part base on id
and type
(given that id="a" and markets.type="car" before updating), which they should all be unique:
for example: use {type: "car3", price: 11200}
to update
{type: "car", price: 10000}
, how can I do it in Mongoose?