Commit 6d58bd8e by Wes Freeman

Add occurrence checking for arrays with nested objects.

parent d025b62d
...@@ -136,16 +136,17 @@ resultsDB[resultsCollectionName].find({}).forEach(function(key) { ...@@ -136,16 +136,17 @@ resultsDB[resultsCollectionName].find({}).forEach(function(key) {
return; return;
} }
if(!(keyName.match(/\.XX/) && !keyName.match(/\.XX$/))) { if(keyName.match(/\.XX/)) {
// i.e. "Unless the key's value is an array which contains arrays" -JC // exists query checks for embedded values for an array
// ...we do not support totalOccurrences for these keys because it is // ie. match {arr:[{x:1}]} with {"arr.x":{$exists:true}}
// a bit too tricky for a 'version 1'. Perhaps we'll support in the future. -JC // just need to pull out .XX in this case
keyName = keyName.replace(/.XX/g,"");
}
var existsQuery = {}; var existsQuery = {};
existsQuery[keyName] = {$exists: true}; existsQuery[keyName] = {$exists: true};
key.totalOccurrences = db[collection].count(existsQuery); key.totalOccurrences = db[collection].count(existsQuery);
key.percentContaining = (key.totalOccurrences / numDocuments) * 100; key.percentContaining = (key.totalOccurrences / numDocuments) * 100;
}
resultsDB[resultsCollectionName].save(key); resultsDB[resultsCollectionName].save(key);
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment