windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server https://softhier.com/ instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

mongoose need help writing query

Asked By: Anonymous

I have a collection with objects that a little cut down look like this:

{symbol: x, timestamp: 2323123132}

Now I receive an Array of "symbols" and two timestamps "fromdate" "todate" via a post request to the API. What I need to query and return back is:

Find and count the occurences of each symbol within that array where the timestamp is within the given date range "fromdate", "todate" and count how many times they occure.

so the output should look like this:

symbol: xy
count: 10

symbol yz
count: 5

and so on.

Could anyone provide me a hint of how to do that using mongoose and node?


Solution

Answered By: Anonymous

Assuming timestamp1, timestamp2 and symbolsArray are the names of your variables and collection is the name of your collection, this could be your query:

collection.find({ "timestamp": { $gte:timestamp1, $lte: timestamp2 }, "symbol" : { $in : symbolsArray });

techinplanet staff


Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno