Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

QueryBuilder multiply and divide support #3373

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

Merged
GromNaN merged 6 commits into mongodb:5.x from faissaloux:querybuilder-multiply-and-divide
Jun 10, 2025

Conversation

@faissaloux
Copy link
Contributor

@faissaloux faissaloux commented Apr 26, 2025

Hello 👋🏻

In this PR I have added multiply and divide to QueryBuilder .

Usage

DB::table('users')->where('name', 'John Doe')->multiply('salary'); // "salary" * 1
DB::table('users')->where('name', 'John Doe')->multiply('salary', 2); // "salary" * 2
DB::table('users')->where('name', 'John Doe')->divide('salary'); // "salary" / 1
DB::table('users')->where('name', 'John Doe')->divide('salary', 2); // "salary" / 2

Checklist

  • Add tests and ensure they pass

florianJacques reacted with rocket emoji
@faissaloux faissaloux requested a review from a team as a code owner April 26, 2025 21:23
Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

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

Thanks for this nice feature that leverage MongoDB update operator.

Could you tell me a bit more about your use-case?

Copy link
Contributor Author

Could you tell me a bit more about your use-case?

Case of storing price in cents

We need to get the price converted from cents to USD.

DB::table('products')->where('title', 'socks')->divide('price', 100);

Case of adding tax

DB::table('products')->where('title', 'socks')->multiply('price', 1.2);

@GromNaN GromNaN modified the milestones: 5.4, 5.5 Jun 10, 2025
@GromNaN GromNaN enabled auto-merge (squash) June 10, 2025 07:57
Copy link
Member

GromNaN commented Jun 10, 2025

Thank you @faissaloux

faissaloux reacted with heart emoji

@GromNaN GromNaN merged commit e2b119a into mongodb:5.x Jun 10, 2025
71 checks passed
@faissaloux faissaloux deleted the querybuilder-multiply-and-divide branch June 10, 2025 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@GromNaN GromNaN GromNaN approved these changes

Assignees

No one assigned

Labels

Projects

None yet

Milestone

5.5

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /