Skip to content

Conversation

@juliusgeo
Copy link
Contributor

No description provided.

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, looks like you need to run pre-commit locally and pull from master to pick up the mypy version pins.

If ``upsert=True`` and no documents match the filter, create a
new document based on the filter criteria and update modifications.
>>> result = db.test.update_one({'x': -1*2**32}, {'$inc': {'x': 3}}, upsert=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about using update_one({'x': -10}, ... instead (for clarity)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense to me. Fixed.

>>> result.upserted_id
ObjectId('626a678eeaa80587d4bb3fb7')
>>> for doc in db.test.find():
... print(doc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed this would make more sense as a find_one:

>>> db.test.find_one(result.upserted_id)
{'_id': ObjectId('626a678eeaa80587d4bb3fb7'), 'x': -7}

@juliusgeo juliusgeo merged commit 05b55e8 into mongodb:master May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants