Replies: 1 comment 2 replies
-
Hi @lkho, I understand your problem. However, I'm not sure if it can be solved, unless we'd build a new I'm converting this to a discussion since I don't think it's an issue with Payload, let me know if you have any questions/suggestions. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the Bug
When calling
payload.db.updateMany
/payload.db.updateJobs
without alimit
orsort
, the returned documents are NOT the updated documents, theoretically.ref:
payload/packages/db-mongodb/src/updateMany.ts
Lines 75 to 105 in 4278e72
Details:
This issue is triggered when the
where
condition conflicts with the updatedata
.e.g. in SQL :
UPDATE table SET processing = true WHERE processing = false
in the task queue workerReason:
when there is no
sort
orlimit
, the code resembles the followingThe
results
will always be empty since after the db is updated, thewhere
clause will never match the updated documents again.Link to the code that reproduces this issue
https://github.com/lkho/payload/tree/bug/updateMany-updateJobs-return-results
Reproduction Steps
I did try to make a reproduction repo, but don't know how to config with the mongodb adapter. The provided repo is just for illustration only.
Just read
test/_community/int.spec.ts
for the illustration.Which area(s) are affected? (Select all that apply)
db-mongodb
Environment Info
Beta Was this translation helpful? Give feedback.
All reactions