Comments (3)
Actually, just need to document this -- @app.before_first_request
already does what we want (and sets up a context, which is what prevents from just having those indexes in the file). Need to be clear in docs that index creation can take a long time and might best be done in a script.
from flask-pymongo.
Tasks like index creation shouldn't live inside the lifecycle of the application, they should really be run as one-off system level tasks.
I personally wouldn't suggest to anyone to run the ensure_index command when starting up an app. If someone was to naively create an index on a massive collection (experience talking) in the foreground you would lock up your entire database whilst it's building.
A better way to do this is just to check for the existence of an index with a specific name or spec and then throw a warning/error if it doesn't exist.
from flask-pymongo.
@markunsworth agreed, we should not encourage people to do unwise things like creating indexes at app-start time, even just in docs. Closing.
from flask-pymongo.
Related Issues (20)
- Authentication issue HOT 1
- Unexpected keyword argument 'lifetime' HOT 3
- Error Handling HOT 2
- TypeError: argument must be an int, or have a fileno() method while trying to use send_file HOT 4
- [Request] Add support for `db` in GridFS functions
- OperationFailure
- Better authentication documentation? HOT 1
- cannot start the motor due to AttributeError: type object 'Cursor' has no attribute 'allow_disk_use' HOT 1
- flask-pymongo version supporting mongo 2.4 (raspbian) HOT 1
- search referncefield HOT 3
- the converter 'ObjectId' does not exist HOT 1
- send_file throwing an error in werkzeug by passing a None-type to function that requires str HOT 2
- hi HOT 6
- hi
- hi HOT 1
- tox command failing on x86_64 and arm64 HOT 4
- Collection.find_one_or_404 hides stack trace
- Flask-Pymongo not connecting to online mongodb HOT 1
- Change in Flask api - JSONProvider interface replaces JSONEncoder
- TypeError while reading files HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-pymongo.