cobrateam / flask-mongoalchemy

Flask support for MongoDB using MongoAlchemy.
https://pythonhosted.org/Flask-MongoAlchemy/
BSD 2-Clause "Simplified" License
217 stars 45 forks source link

suggestion for query simplification #30

Open colwilson opened 12 years ago

colwilson commented 12 years ago

Would it not be better to let this work:

books = Book.query.filter(Book.author == author).first()

rather than:

books = Book.query.filter(Book.author.mongo_id == author.mongo_id).first()
AndySum commented 10 years ago

I just stumbled across this issue with my project as well.

I tried the above method you suggested, and it actually worked sporadically for my queries. It would work on localhost, but not on Heroku, both with the same shared database.

When I switched to the second method (as it seems you have to), it started working the same on both systems.

It would be good to have an example on this at the very least, but I agree with your suggested simplification.