MongoDB 向 NodeJS 中的现有用户插入数据
MongoDB insert data to an existing user in NodeJS
我想问问你是否可以向现有用户插入一些新数据,
无需从之前添加它们,而仅通过在模型中定义它们。
这可能吗?如果可以的话如何?
如果您不明白其中的任何部分,请告诉我。
https://docs.mongodb.com/manual/reference/method/db.collection.update/
mongodb.someCollection.update(
{/* some query to match the record or not */},
{/* record to update OR record to insert if no match */},
{
/* options */
upsert: true
}
)
我想问问你是否可以向现有用户插入一些新数据,
无需从之前添加它们,而仅通过在模型中定义它们。
这可能吗?如果可以的话如何?
如果您不明白其中的任何部分,请告诉我。
https://docs.mongodb.com/manual/reference/method/db.collection.update/
mongodb.someCollection.update(
{/* some query to match the record or not */},
{/* record to update OR record to insert if no match */},
{
/* options */
upsert: true
}
)