A little improvment for the Express middleware :)#92
A little improvment for the Express middleware :)#92julien51 wants to merge 1 commit intodresende:masterfrom julien51:master
Conversation
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.
|
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. |
|
Dang. Indeed... but how do you then make sure that the _db variable is defined? |
|
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. |
…efore processing requests (#92)
|
Can you please test the latest commit? It should queue the requests while the connection is not established. |
|
@dresende I haven't had the time to fully test it, but it looks like it works great :) |
|
So, I installed the library again today and it looks like the issue is back :( |
|
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? |
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.