Skip to content

Tag: mongodb

How can I limit output of MongoDB query in Python?

I have this example MongoDB entry in a users DB: And I’m using Pymongo to query the file named “test”: users.find_one({‘files.filename’:”test”}) How can I limit the output from Pymongo, so it only gives me the dict where “test” is contained? In other words…

Aggregation $match within a $sum

I was wondering if it was possible to somehow use the $match operator within the $sum function for aggregation. I want to be able to use the value of the $sum operator within the project fields somehow, I just don’t really understand what the right approach would be for this. Sample Input (may be too lo…

User-created Record Fields

I am creating a web-app w/ Flask + Flask-WTF that has CRM-like features as a project. My current database (MongoDB) structure is I have: Users who can login, People who are assigned to users, and Records who are assigned to people. People have various fields to be filled out (Name, Phone Number, Email, etc). …

Does mongo db ListField maintain ordering?

If I add items to a ListField on a mongo db document in a specific order and then write it to the database, is it guaranteed that all subsequent reads will see the list in the same order? e.g. write read this is using python mongoengine ORM v0.4.2 Answer Yes they do, the driver is faithful to the underlying d…

Convert SQL Query to MongoDB syntax

I have a big problem with converting SQL queries to Mongo DB for Python. I have a question if you know better methods for transferring SQL queries to Mongo DB queries? I have two queries but I still have big problems with the syntax conversion to Mongo DB. Maybe there is someone here who can help me? Table I …