Log file Viewer
Help
|
Karma
| Search:
#mongodb logs for Friday the 21st of December, 2018
(
Back to #mongodb overview
) (
Back to channel listing
) (
Animate logs
)
[
16:02:12
] <
Lope
> I'm having an issue in node.js
[
16:02:45
] <
Lope
> products.updateOne({cPuI: currentProductUrlIndex}, productInfo, {upsert:true});
[
16:03:24
] <
Lope
> MongoError: the update operation document must contain atomic operators.
[
16:03:54
] <
Derick
> that sounds about right
[
16:04:02
] <
Derick
> if you want to replace all data, you need to use replaceOne
[
16:04:26
] <
Derick
> and if you want to update only some fields, productInfo needs to look like: { $set: { field: newvalue, field2: newvalue }}
[
16:05:44
] <
Lope
> Derick, oh, great, i didn't know there's a method called replaceOne
[
16:05:57
] <
Lope
> Sounds perfect. Can replaceOne do upsert?
[
16:06:09
] <
Derick
> I believe so
[
16:06:20
] <
Lope
> Ah, I see so :)
[
16:06:39
] <
Derick
> https://stackoverflow.com/questions/35848688/whats-the-difference-between-replaceone-and-updateone-in-mongodb explains it