I’m storing a single word in the database using the following:
collection.update({},{$set:{word:newWord}},{upsert:true},function(){
collection.find().nextObject(function(err, results) {
oldWord = results;
console.log("New Word: " + results);
});
});
here is an example of my DB
{ "_id" : ObjectId("4ff92def446ce41df5692385"), "word" : "asdf" }
Every time it gets to the console.log line, it looks like:
New Word: [object Object]
I’m trying to isolate “asdf” (sans quotes) from the above record. I’ve tried everything from toArray, nextObject, etc.
What am I missing? I’ve been trying for hours!
If you’re interested in some field, you should print that, not the whole object (mainly because string representation of objects in Javascript isn’t very helpful).