Good, I've been looking for information for a couple of days to be able to do this search
Search for books written by 2 authors
I'll pass you a screenshot of how it is stored in my MongoDB
I get used to the idea that "author" is an array and there must be some possible way to tell the statementfind
"author".count() = 2
But I can't find anything...
Any help is welcome!
You can use the operator
all
to get the documents that include all the elements of the array.If you use
mongoose
:Update
In that case you can add the operator
$size
for:Example:
The above translates to: "Find all books that are written only by X and Y author" .