Gist gives me this, after modding to add authentication (I have to
have authentication):
var util = require('util');
var m = require("mongodb");
var msrv = new m.Server("localhost", 27017,
{ auto_reconnect:true,poolSize:1,safe:true });
var db = new m.Db('tinhalo', msrv);
db.open(function(err,connection) {
db.authenticate("myuser", "mypass", function (err, val)
{ if(err) throw new Error(err); });
connection.collection('staff',function(err,collection) {
if(err) throw new Error(err);
collection.find({},function(err,cursor) {
cursor.toArray(function(err,items) {
if(err) throw new Error(err);
console.log('FOUND:
'+util.inspect(items));
});
});
});
});
ubuntu@may:/srv/node/tinhalo$ sudo node ./site.js
node.js:134
throw e; // process.nextTick error, or 'error' event on first
tick
^
Error: unauthorized db:tinhalo lock type:-1 client:127.0.0.1
at /srv/node/tinhalo/site.js:16:47
at /home/ubuntu/.node_libraries/.npm/mongodb/0.9.7-2-3/package/lib/
mongodb/cursor.js:129:30
at /home/ubuntu/.node_libraries/.npm/mongodb/0.9.7-2-3/package/lib/
mongodb/cursor.js:173:32
at /home/ubuntu/.node_libraries/.npm/mongodb/0.9.7-2-3/package/lib/
mongodb/cursor.js:471:67
at [object Object].close (/home/ubuntu/.node_libraries/.npm/
mongodb/0.9.7-2-3/package/lib/mongodb/cursor.js:679:5)
at Object.callback (/home/ubuntu/.node_libraries/.npm/mongodb/
0.9.7-2-3/package/lib/mongodb/cursor.js:471:21)
at /home/ubuntu/.node_libraries/.npm/mongodb/0.9.7-2-3/package/lib/
mongodb/connection/server.js:253:32
at [object Object].parseBody (/home/ubuntu/.node_libraries/.npm/
mongodb/0.9.7-2-3/package/lib/mongodb/responses/mongo_reply.js:110:5)
at [object Object].<anonymous> (/home/ubuntu/.node_libraries/.npm/
mongodb/0.9.7-2-3/package/lib/mongodb/connection/server.js:242:24)
at [object Object].emit (events.js:64:17)
And I have been going through the examples, but they drop either the
db or the collection before doing anything else... which confuses me
if I want to use existing data. What I am shooting for is to tie this
to MVVMC with Jade, so I have to take baby steps. This has been a big
hangup for me after days of searching. Of course, the next question I
am going to ask is how to take the cursor.toArray and pass it up the
chain so I can view it in a webpage.
>
hsilber...@ngmoco.com
>
415-606-1312