i have an schema as follows:
email = ({
emailid: String,
body: String
});
thread = ({
threadid: String,
emails: [email]
});
User = ({
username: String,
threads: [thread],
lastmsg: String,
lastthread: String
});
so as you can see for a particular instance of user it can have multiple instances of threads and for a single instance of user it can have multiple instances of emails.
In each email we have body which contains the contents of mail. Now i have a search query (a single word) lets say the variable "query".
Now i want to search for the first 10 instances of the emails with the query word in their body. The search should start from the last entry in database to the first entry(i.e in reverse order). What will be the monogodb query fo this in nodejs.
via Avy