Skip to content

A little improvment for the Express middleware :)#92

Closed
julien51 wants to merge 1 commit intodresende:masterfrom
julien51:master
Closed

A little improvment for the Express middleware :)#92
julien51 wants to merge 1 commit intodresende:masterfrom
julien51:master

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