I'm playing with nodeJS and mongoJS. I've successfully queried the DB and returned a set of data:
var databaseUrl = "redirect"; // "username:[email protected]/mydb"
var collections = ["things", "reports"]
var db = require("mongojs").connect(databaseUrl, collections);
db.things.find({url: "google.com"}, function(err, things) {
if( err || !things) {
console.log("URL not Found");
}
else things.forEach( function(RedirectURL) {
console.log(RedirectURL);
} );
});
This returns this:
{ _id: 4fb2c304f2dc05fe12e8c428,
url: 'google.com',
redirect:
[ { url: 'www.goolge.com', weight: 10 },
{ url: 'www.google.co.uk', weight: 20 } ] }
What I need to do now is select certain elements of the array such as redirect.weight or redirect.url.
Does mongoJS allow me to do this easily or is there a better way?
Any pointers greatly appreciated as ever!
Ric