Relrin/sanic-mongodb-extension

your project/example doesn't work

Closed this issue · 1 comments

subject says it all.

"NoDBDefinedError"

Hello, @kevin

Thank you for opening an issue here.

I figured out why this (or similar) error raises in runtime when you are trying to get an access to the root endpoint in example:

  1. In the most cases uMongo instances are expecting that the database, that gonna be used, will be created / initialized before an access to it.
  2. From the some point of view the lazy instance in the one file with handlers and table descriptions probably is not a good idea, because the lazy instance will be initialized later, when the application will be started. It leads to the situation when you're correctly initialized the table with LAZY_UMONGO variable and expecting that everything will work fine, but the endpoint handler can't get an access to the data, because it used a different copy of the lazy instance. To avoid this issue I've made a small fix and the new release as well.

And small comments for people that would like to reuse the example:

  • The example in README file was done with the development environment, via docker-compose tool. So, just use docker-compose -f docker-compose.dev.yml up -d from the root folder of this repository and after go into the app container and play around in this sandbox.
  • I also added a bunch of web applications that I've written with this extension into the end of README file, so with that you can understand which the project structure can be (as the one of possible ways to organize) with using lazy instances.