Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reimplement MongoCollection.find with projection #2694

Merged
merged 4 commits into from
Oct 28, 2022

Conversation

WebFreak001
Copy link
Contributor

@WebFreak001 WebFreak001 commented Oct 26, 2022

Also tests it + fixed examples + fixed deprecations

Restores backwards compatibility with older code using returnFieldMapping. I noticed the old remove/update functions are always gonna still use the old behavior. We could in theory add compatibility layers there to let users just use the old API, but I would prefer users to upgrade to the better standardized API that's common across all drivers.

Copy link
Contributor

@Geod24 Geod24 left a comment

Choose a reason for hiding this comment

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

Feel free to set auto-merge after the minors adjustments.

@@ -376,6 +394,33 @@ struct MongoCollection {
return MongoCursor!R(m_client, m_db.name, m_name, flags, num_skip, num_docs_per_chunk, query, returnFieldSelector);
}

/**
Queries the collection for existing documents, limitting what fields are
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: Limiting


See_Also:
- Querying: $(LINK http://www.mongodb.org/display/DOCS/Querying)
- Projection: $(LINK https://www.mongodb.com/docs/manual/tutorial/project-fields-from-query-results/#std-label-projections)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -80,7 +80,7 @@ struct MongoCollection {
Throws: Exception if a DB communication error occurred.
See_Also: $(LINK http://www.mongodb.org/display/DOCS/Updating)
*/
deprecated("Use updateOne or updateMany taking UpdateOptions instead, this method breaks in MongoDB 5.1 and onwards.")
deprecated("Use replaceOne, updateOne or updateMany taking UpdateOptions instead, this method breaks in MongoDB 5.1 and onwards.")
Copy link
Contributor

Choose a reason for hiding this comment

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

"Use `replaceOne`, `updateOne`, ..."

The frontend will then highlight it as it highlights keywords.

@Geod24
Copy link
Contributor

Geod24 commented Oct 27, 2022

Thanks a lot for this, I think it'll make this module much more accessible!

Copy link
Member

@s-ludwig s-ludwig left a comment

Choose a reason for hiding this comment

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

Looks good apart from the get!T behavior change.

data/vibe/data/bson.d Show resolved Hide resolved
Also tests it + fixed examples + fixed deprecations
Was dropped with MongoDB 5.1, retrieve errors directly from the command
responses (implictly done by MongoDriverException) instead
@WebFreak001
Copy link
Contributor Author

adjusted to reviews

@Geod24
Copy link
Contributor

Geod24 commented Oct 28, 2022

CI is red

Before, Bson values must have been of type long for get!long to work,
now Bson values of type int also work with to!long.

Additionally to!double now supports long and int as well.

This is useful especially for MongoDB, where return types are not
strictly specified.
@WebFreak001
Copy link
Contributor Author

CI fixed

@Geod24 Geod24 merged commit 83208ee into vibe-d:master Oct 28, 2022
@WebFreak001 WebFreak001 deleted the vibe-9-mongo-compat branch October 28, 2022 13:25
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.

None yet

3 participants