'Finding the Entries between two Entries in MongoDB

I want to find two different entries in my MongoDB Collection. Then I want to get all the entries that lie between these two.

e.g.

_id: 1 pet: cat

_id: 2 pet: dog

_id : 3 pet: cow

_id: 4 pet: rabbit

_id: 5 pet: crocodile

_id: 6 pet: Pig

Now I want to get all the data between crocodile and dog => I get Dog, Cow, Rabbit, Crocodile.

How does the model.find() function look like?

Thanks in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source