vibe.d mongo updateOne error

Ben Jones fake at fake.fake
Fri Apr 21 20:46:36 UTC 2023


I'm trying to update an app from an older version of Vibe.d to a 
newer version that supports modern Mongo (0.9.7-alpha2)

I'm replacing an older call to collection.update() to 
collection.updateOne() instead.  I had to change the options 
parameter to an updated struct, and it now compiles, but I'm 
getting a runtime error:

```Passed in a regular document into a place where only updates 
are expected. Maybe you want to call replaceOne instead? (this 
update call would otherwise replace the entire matched object 
with the passed in update object)```

On this command

  _reviews.updateOne(["name" : reviewee], ["$push" : ["reviews" : 
ins]], options);

The code 
(https://github.com/vibe-d/vibe.d/blob/a1122a0d5c2e1a19ab6fe318cb47784b76d29336/mongodb/vibe/db/mongo/collection.d#L319) looks like it's checking the query part (the first parameter) to find a dollar sign to tell that it's an update, not a document, but I don't understand why.  This looks like the queries I see in the mongo doc as well as the mongo session store in vibe: https://github.com/vibe-d/vibe.d/blob/83208ee8d824e28f3e35042e0425026765e47d12/mongodb/vibe/db/mongo/sessionstore.d#L101

Any idea what's going wrong?


More information about the Digitalmars-d-learn mailing list