I have uploaded the following JSON file into a mongoDB database: https://cloudpricingcalculator.appspot.com/static/data/pricelist.json
I have succeeded in accessing it using the following line in my app.js:
db.googlepricelist.find({},
{"gcp_price_list":1}).pipe(JSONStream.stringify()).pipe(res);
I would like to query all objects in object gcp_price_list
, where the name of the object contains substring "VMIMAGE".
So for example bellow objects:
"CP-COMPUTEENGINE-VMIMAGE-F1-MICRO"
"CP-COMPUTEENGINE-VMIMAGE-G1-SMALL"
I can't figure out how to define a query which is able to do this.
So far I tried this:
db.googlepricelist.find({$where: function() {
for (var key in this.gcp_price_list) {
if (key.indexOf("VMIMAGE")!=-1) {
return true;
}
return false;
}
},}).pipe(JSONStream.stringify()).pipe(res);