Giter Club home page Giter Club logo

Comments (3)

dcrosta avatar dcrosta commented on September 13, 2024

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.

markunsworth avatar markunsworth commented on September 13, 2024

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.

dcrosta avatar dcrosta commented on September 13, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.