-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Open
Labels
bounty:$100Bounty applies for fixing this issue (Parse Bounty Program)Bounty applies for fixing this issue (Parse Bounty Program)type:featureNew feature or improvement of existing featureNew feature or improvement of existing feature
Description
New Feature / Enhancement Checklist
- I am not disclosing a vulnerability.I am not just asking a question.I have searched through existing issues.To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Current Limitation
Parse does not natively support a way to issue a query and in the same operation write to the found documents. This is a concept used to uniquely process documents in an environment with concurrent operations.
Feature / Enhancement Description
Add a method set
or update
to Parse.Query
that if set executes Parse.Query.first
as a findAndModify
in MongoDB.
Example Use Case
- Request A is a
findAndModify
request for documents that are without a "being processed" flag, which returns one document which will be flagged as being processed immediately. - Request B is the same as request A and has been issued at the time as request A. No document is returned, which ensures the same document is not being processed twice.
Alternatives / Workarounds
- Use transactions, which may have an unnecessary performance impact
- Directly access the DB adapter, see How to use Mongo's findOneAndUpdate. #4258
- Maintain a custom DB connection, directly interacting with the DB driver
Metadata
Metadata
Assignees
Labels
bounty:$100Bounty applies for fixing this issue (Parse Bounty Program)Bounty applies for fixing this issue (Parse Bounty Program)type:featureNew feature or improvement of existing featureNew feature or improvement of existing feature
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
parse-github-assistant commentedon Feb 21, 2022
Thanks for opening this issue!
[-]Support MongoDB's findOneAndModify[/-][+]Support MongoDB's findAndModify[/+]iMac7 commentedon May 16, 2024
I don't get this part, would the new query look like,
Parse.Query.set( )
orParse.Query.first(val, opts)
?mtrezza commentedon May 16, 2024
In a collection with N documents that match the query this query returns 1 matching document and at the same time sets status to
grabbed
, all in a single DB request using MongoDB'sfindAndModify
operator.We should look into the MongoDB docs to see whether
set
,update
ormodify
make most sense semantically, to not cause confusion with other operators.iMac7 commentedon Jun 14, 2024
I see that a
findOneAndModify
is available in parse server already. Should this be solved in the sdk by conditionally changing the operation thatParse.Query.first()
executes?Is there something to be done on the server?
mtrezza commentedon Jun 14, 2024
Not sure if Parse Server supports
findOneAndModify
yet, even though it may be used internally for some operations. This would need to be implemented in the REST API, and I guess as you said, the client SDK should use that endpoint conditionally if the query contains aset
.