Skip to content
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

A little improvment for the Express middleware :) #92

Closed
wants to merge 1 commit into from
Closed

A little improvment for the Express middleware :) #92

wants to merge 1 commit into from

Conversation

julien51
Copy link

Making sure we do only proceed to next() in the middleware when the database is ready.
doing so before will trigger errors as the _db variable may still be undefined.

Making sure we do only proceed to next() in the middleware when the database is ready.
doing so before will trigger errors as the _db variable may still be undefined.
@dresende
Copy link
Owner

That's good but you can't move the variables to inside the exports, because you might have more than one connection and the db will then be an Array of connections.

@julien51
Copy link
Author

Dang. Indeed... but how do you then make sure that the _db variable is defined?

@dresende
Copy link
Owner

If it is in the "global" scope of the orm express file, it's accessible. I like your idea and I'm going to make an option (defaulted to true) to halt express requests while all the defined connections are not established.

dresende added a commit that referenced this pull request Mar 26, 2013
@dresende
Copy link
Owner

Can you please test the latest commit? It should queue the requests while the connection is not established.

@julien51
Copy link
Author

@dresende I haven't had the time to fully test it, but it looks like it works great :)
Thanks!

@julien51 julien51 closed this Mar 28, 2013
@julien51
Copy link
Author

So, I installed the library again today and it looks like the issue is back :(

@julien51 julien51 reopened this Jun 10, 2013
@dresende
Copy link
Owner

What happens exactly? You have access to db object but you can't do anything because it's not connected yet or does it return null or something?

@dresende dresende closed this Jul 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants