mongoskin

MongoSkin “Cannot read property 'apply' of undefined”

假装没事ソ 提交于 2019-12-07 18:14:28
问题 I'm trying to use MongoSkin in NodeJS, and I have this code: var mongoskin = require('mongoskin'); var db = mongoskin.db("mongodb://localhost:27017/database"); var collection = db.collection('test'); collection.find().toArray(function(err, items) { db.close(); }); yet it returns this error: TypeError: Cannot read property 'apply' of undefined at EventEmitter.<anonymous> (C:\Users\user\node_modules\mongoskin\lib\collection.js:51:21) at Object.onceWrapper (events.js:273:13) at EventEmitter.emit

MongoError: driver is incompatible with this server version

北战南征 提交于 2019-12-07 03:58:50
问题 I've just installed Mongo, Node, etc. and when I try to update the database via my nodejs server, I get this error: MongoError: driver is incompatible with this server version Here are the versions I have: Node v0.12.2 (latest is v0.12.3) Express v4.12.4 (latest is v4.12.4) Mongodb v3.0.3 (latest is v3.0.3) Mongodb Node.js Driver v2.0.33 (latest is v2.0.33) Mongoskin v1.3.23 (latest is v1.3.23) I have the latest versions of everything, and I've searched the node mongodb driver git to find out

Is there a way to list collections with mongoskin?

柔情痞子 提交于 2019-12-06 12:00:42
I already have an established database connection. I need to list the names of the collections in the database. Is it possible? To show collections into database from mongo shell : db.getCollectionNames() So to show collection in mongoskin try that var collections = db.collections(); collections.each(function(err, collection) { console.log(collection); }); according to this link Mongoskin Tutorial db.collectionNames(function(err, collectionArrayResult) { //Now do something with collectionArrayResult }); The result is an array of objects with a 'name' property, like this: [ { name: '<dbName>.

Updating an array item using NodeJS, MongoDB & Monk

ぃ、小莉子 提交于 2019-12-06 03:21:01
问题 I have a data set like this: { name : 'Doc Name', photos: [ { name: 'photo1', url: 'http://.....' }, { name: 'photo2', url: 'http://......' } ], etc ... Using Monk https://github.com/LearnBoost/monk how do I update photo2? I can use an index as I am iterating over the fields at the moment. My current attempt below gives me an error, and I can't use a variable for the JSON selector (as in the index). collection.update({_id: data._id}, {photos[i].data: filename}, function(err, updatedata) { });

MongoSkin “Cannot read property 'apply' of undefined”

无人久伴 提交于 2019-12-05 21:33:45
I'm trying to use MongoSkin in NodeJS, and I have this code: var mongoskin = require('mongoskin'); var db = mongoskin.db("mongodb://localhost:27017/database"); var collection = db.collection('test'); collection.find().toArray(function(err, items) { db.close(); }); yet it returns this error: TypeError: Cannot read property 'apply' of undefined at EventEmitter.<anonymous> (C:\Users\user\node_modules\mongoskin\lib\collection.js:51:21) at Object.onceWrapper (events.js:273:13) at EventEmitter.emit (events.js:182:13) at C:\Users\user\node_modules\mongoskin\lib\utils.js:134:27 at result (C:\Users

Node.js promises with mongoskin

走远了吗. 提交于 2019-12-05 10:59:28
I'm trying to avoid using callbacks when making mongodb queries. I'm using mongoskin to make calls like so: req.db.collection('users').find().toArray(function (err, doc) { res.json(doc); }); In many cases I need to make multiple queries so I want to use Node.js promise library but I'm not sure how to wrap these functions as promises. Most of the examples I see are trivial for things like readFile , I'm guessing in this case I would need to wrap toArray somehow? Can this be done or would have to be something implemented by mongoskin? An example could be any set of callbacks, find/insert, find

Does run mongoskin only with mongodb version 1.4 and older?

纵饮孤独 提交于 2019-12-04 13:14:07
问题 I'm trying to understand nodejs, express and mongodb I'm running mongodb v 2.0.6 and latest nodejs and express and trying to connect express application with mongodb through mongoskin. the problem is: npm ERR! peerinvalid The package mongodb does not satisfy its siblings' peerDependencies requirements! npm ERR! peerinvalid Peer mongoskin@1.4.13 wants mongodb@~1.4 Does it mean that mongoskin can work only with mongodb v 1.4? This version is to old as for me (current is 3) 回答1: It's expecting

Updating an array item using NodeJS, MongoDB & Monk

梦想与她 提交于 2019-12-04 10:11:38
I have a data set like this: { name : 'Doc Name', photos: [ { name: 'photo1', url: 'http://.....' }, { name: 'photo2', url: 'http://......' } ], etc ... Using Monk https://github.com/LearnBoost/monk how do I update photo2? I can use an index as I am iterating over the fields at the moment. My current attempt below gives me an error, and I can't use a variable for the JSON selector (as in the index). collection.update({_id: data._id}, {photos[i].data: filename}, function(err, updatedata) { }); Updating items at a position in an array can be done using the positional $ operator collection.update

Does run mongoskin only with mongodb version 1.4 and older?

十年热恋 提交于 2019-12-03 09:08:27
I'm trying to understand nodejs, express and mongodb I'm running mongodb v 2.0.6 and latest nodejs and express and trying to connect express application with mongodb through mongoskin. the problem is: npm ERR! peerinvalid The package mongodb does not satisfy its siblings' peerDependencies requirements! npm ERR! peerinvalid Peer mongoskin@1.4.13 wants mongodb@~1.4 Does it mean that mongoskin can work only with mongodb v 1.4? This version is to old as for me (current is 3) It's expecting version 1.4 of the MongoDB driver , not the database. You should remove the 2.0.6 version of the driver, as

Configuring Node.js Connection String for Mongo Labs Database on Heroku

南笙酒味 提交于 2019-12-01 13:43:01
My web app (built on Node.js and Express) works fine locally, but when I deploy it to Heroku, I'm unable to connect to my Mongo Labs database. I've changed the connection string in my 'app.js' file to properly reflect the URI of the new Heroku Mongo Labs database (fake username and password substituted below). I've also tried several stackoverlow solutions can't connect to mongolab with node.js on heroku as well as https://devcenter.heroku.com/articles/getting-started-with-nodejs#using-mongodb but those don't seem to work either. I suspect this is slightly different because I'm using Mongoskin