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

The limit doesn't work with updateMany. #378

Open
SittiphanSittisak opened this issue Jun 10, 2024 · 2 comments
Open

The limit doesn't work with updateMany. #378

SittiphanSittisak opened this issue Jun 10, 2024 · 2 comments

Comments

@SittiphanSittisak
Copy link

SittiphanSittisak commented Jun 10, 2024

I tried with

    final selectorBuilder = where
      ..eq(...)
      ..eq(...)
      ..get(...)
      ..notExists(...)
      ..limit(3)
      ..sortBy(...);
    final modifierBuilder = modify.set(..., ...);
    final result = await _dbCollection.updateMany(selectorBuilder, modifierBuilder);

The result of result.nModified is the number of all documents that match and these documents were updated.
How to use limit and sortBy with updateMany?

@giorgiofran
Copy link
Contributor

Hi, the limit is not an available parameter for the update (in general) function. Check the following to see a possible solution.
For the sortBy I will have to do a fix.

@giorgiofran
Copy link
Contributor

Also the sortBy is not an updateMany parameter. In this case you can use the hint (index name) or hint document (index description) to suggest the server to order in a certain way. Consider that it is just an hint, and the server could decide to use another index.

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

No branches or pull requests

2 participants