-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mongodb support #117
base: master
Are you sure you want to change the base?
Mongodb support #117
Conversation
Hey travis, thanks bro! |
@coderarity - The process is hanging when trying to run the basic examples. For instance: var resourceful = require('../lib/resourceful');
resourceful.use('mongodb');
var Author = resourceful.define('author');
Author.string('name');
Author.create({
id: 'Marak'
}, function(err, marak){
console.log(marak);
}); Outputs: node examples/create.js
{ id: 'Marak', name: undefined, resource: 'Author' }
But then just hangs and the process never closes. Any ideas? |
I see. I think mongodb needs to close the database before exiting, but there's nothing to support that in resourceful. Any idea how I can go about closing the mongodb client? |
The best action might be requiring the user to explicitly call I'm not sure of any other logical way it could be handled. On Thu, Sep 6, 2012 at 5:16 PM, Christian Howe [email protected]:
|
I looked into how mongoose handles this, and it appears they are using a state machine to keep track of all connections and disconnections. I'm not too keen on refactoring the way resourceful handles engine connections right now. @coderarity - Have you done any testing to see how connection pooling is handled with the I'm OK with the examples hanging for now and the connection not closing, but we need to make sure that connection pooling is happening for outgoing requests. The concern here would be getting into a situation where every new resource instance or resource method call would invoke an additional connection to the database, instead of intelligently sharing / pooling connections. |
Any chance to get this merged in? |
yeah, I'll get it merged in soon, we have to make some changes based on what marak was saying. |
Is it possible to use default mongo-style id with that engine? |
Hi @coderarity, It seems that there's being some change in the way mongodb driver is called. When I try to use the mongodb branch I apparently no connection is made and the following message appears:
Also, is there plans to merge this engine into the master branch? Cheers, Eric. |
I like the idea, considering that people still want to use MongoDB. In my opinion, however, this should be a seperate module. |
Oh, and as to the disconnection problem - we could possibly unref the socket it's using. I'll try and see if that's possible. |
@mmalecki I think, CouchDB should also be a separate module. So you can plug-in only what one you need. |
On the issue of closing mongodb: my understanding is that the Node approach is to use one mongoDB session everywhere. That can be accomplished simply in resourceful/mongodb by handling a property in the config argument to MongoDb creation: |
Hey, I added mongodb support!
It includes tests that use localhost mongodb, so you have to make sure to run
mongod
in some other terminal before running the tests. The engine passes all of the tests.It does some funny stuff involving checking for a fully connected client before running a command so that it can run some setup logic first. Most of that is in the request and setup functions. It'd be nice if we could move this into resourceful somehow, there must be some other engine that has initialization logic as well that is struggling.
There's a mongodb-support-2 branch which was pushed by accident in an attempt to not force-push to mongodb-support, which I ended up doing anyways. (It was because I ran
git rebase master
on the mongodb-support branch). In any case, I checked to make sure it'd easily rebase onto master, so all that should need to be done isgit rebase mongodb-support
to integrate this. Github seems to be fine with it.Anyways, thanks!