I have a collection with one document. It looks like this:
words: {
wordOne: ["Cat", "Dog","Fish"],
wordTwo: ["Red", "Blue", "Green"],
wordThree: ["Square","Cirecle","Triangle"]
}
I would like to query the DB to select a random key (wordOne, wordTwo or wordThree) and then return a random word from the array on that key.
So far I've written a query that returns the entire document and then I use JS to select a random key and then a random word. That does work of course but I've read that if you can have the DB do the work, it's better to do it that way. Plus I'm really curious how it would be accomplished.
I'm using Node and mongoose