scttnlsn / backbone.io

Backbone.js sync via Socket.IO
http://scttnlsn.github.io/backbone.io
541 stars 66 forks source link

Add a simple pure mongo wrapper. #29

Closed xaiki closed 11 years ago

xaiki commented 11 years ago

I have mutating documents that I store in classes that inherits, so having to specify a Mongoose model is a bit too much for my needs. hence I've written this simple MongoDB middleware, so that I can do:

var mediabackend = backboneio.createBackend(); mediabackend.use(backboneio.middleware.mongoStore('mediadb', 'medias'));

and have everything automagically sync'd.

scttnlsn commented 11 years ago

Awesome! Couple things:

xaiki commented 11 years ago

I'm not sure I can pass server,

Error: A Server or ReplSet instance cannot be shared across multiple Db instances at new Db (/home/xaiki/src/TV/mbc-playout/node_modules/mongodb/lib/mongodb/db.js:72:11) at Object. (/home/xaiki/src/TV/mbc-playout/node_modules/backbone.io/middleware/mongoStore.js:11:10) at Object. (/home/xaiki/src/TV/mbc-playout/server.js:107:39) at Module._compile (module.js:446:26) at Object..js (module.js:464:10) at Module.load (module.js:353:32) at Function._load (module.js:311:12) at Array.0 (module.js:484:10) at EventEmitter._tickCallback (node.js:190:39)

scttnlsn commented 11 years ago

My mistake...I meant the Db object.

xaiki commented 11 years ago

ok, implemented.

scttnlsn commented 11 years ago

Looking at this closer I think there are too many cases to handle for it to make sense to include this. What about auth? If the user passes in a connection URL then we need to create the server and db objects ourself. Is the Mongo module installed? etc.

Take a look at https://github.com/kissjs/node-mongoskin or https://github.com/gett/mongojs. Including a middleware for those libs might make a little more sense since they provide a more straightforward API.

xaiki commented 11 years ago

Yeah, sorry i forgot no update about this.

It's not really working, as when you do a collection call it stays in the db On Dec 9, 2012 3:03 PM, "Scott Nelson" notifications@github.com wrote:

Looking at this closer I think there are too many cases to handle for it to make sense to include this. What about auth? If the user passes in a connection URL then we need to create the server and db objects ourself. Is the Mongo module installed? etc.

Take a look at https://github.com/kissjs/node-mongoskin or https://github.com/gett/mongojs. Including a middleware for those libs might make a little more sense since they provide a more straightforward API.

— Reply to this email directly or view it on GitHubhttps://github.com/scttnlsn/backbone.io/pull/29#issuecomment-11173579.