We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
MongoDB Reference
Example model: class Thing(Model): array: List[int]
class Thing(Model): array: List[int]
Array containing the number 42 at least once:
Thing.array.any().eq(42) eq(Thing.array.any(), 42) Thing.array.any() == 42 42 in Thing.array # if possible using __contains__
Array containing only elements greater than 12:
Thing.array.all().gt(42) gt(Thing.array.all(), 42) Thing.array.all() > 42
Array containing more than 3 elements:
Thing.array.size().gte(3) gte(Thing.array.size(), 3) Thing.array.size() >= 3 len(Thing.array) >= 3 # if possible
The text was updated successfully, but these errors were encountered:
When will be the next release? I would love to have this feature.
But I really need sequences over EmbeddedModels, and I don't know if I should open a new issue (or there is already one) e.g.:
class EmbeddedAuthor(EmbeddedModel): name: str year: int class Book(Model): title: str authors: List[EmbeddedAuthor]
The query could be something like:
Book.authors.any(EmbeddedAuthor.name == "Frederick Forsyth")
but I would love much more:
Book.authors.any().name == "Frederick Forsyth"
Looking about what MongoDB allows to do, it seems that we can query over arrays with the "any" operator transparently, i.e.:
Thing.array.any() == 42
and
Thing.array == 42
would be the same. This is especially interesting for embedded models:
Book.authors.name == "Frederick Forsyth"
which should read like "Tell me which books have at least one author with name "Frederick Forsyth".
Thanks again for this great piece of software.
Sorry, something went wrong.
Hey @erny. Thanks for your enthusiasm 😄 . I'm currently working on this feature, release should come soon 😉
I totally agree with the use case you described and it should definitely possible to have it with this feature !
Any update on that?
Successfully merging a pull request may close this issue.
Suggested implementation of $elemMatch $all and $size
MongoDB Reference
$elemMatch
Array containing the number 42 at least once:
$elemMatch
Array containing only elements greater than 12:
$size
Array containing more than 3 elements:
The text was updated successfully, but these errors were encountered: