I have two existing collections and need to fill out a third, based on a comparison between two existing ones. Two collections to be compared have the following scheme:
Settings collection { "Identifier":"ABC123", "C":"1", "U":"V", "Low":116, "High":124, "ImportLogId":1 } Data collection { "Identifier":"ABC123", "C":"1", "U":"V", "Date":"11/6/2013 12AM", "Value":128, "ImportLogId": 1 }
I am new to MongoDB and NoSQL in general, so itβs hard for me to have time to do this. SQL would look something like this.
SELECT s.Identifier, r.ReadValue, rU, rC, r.Date FROM Settings s JOIN Reads r ON s.Identifier = r.Identifier AND sC = rC AND sU = rU WHERE (r.Value <= s.Low OR r.Value >= s.High)
In this case, using the sample data, I would like to return the record, because the value from the data collection is greater than the high value from the collection of settings. Is this possible with Mongo queries or map shrinking, or is this a bad collection structure (i.e. maybe it should all be in one collection)?
A few additional notes: A collection of settings should have only 1 entry for "Identifier". Data collection will have many entries on the "Identifier". This process can potentially scan hundreds of thousands of documents at a time, so looking at resources is somewhat important.
source share