Questions tagged [mongoengine]

MongoEngine is a Document-Object Mapper (think ORM, but for document databases) for working with MongoDB from Python. It uses a simple declarative API, similar to the Django ORM.

MongoEngine is a Document-Object Mapper (think ORM, but for document databases) for working with MongoDB from Python. It uses a simple declarative API, similar to the Django ORM.

1823 questions
82
votes
5 answers

Flask throwing 'working outside of request context' when starting sub thread

I am trying to start a new thread in Python inside of a Flask application. I am doing background work that gets triggered by the request, but I don't need to wait for the work to be done to respond to the request. Is it possible to set the flask…
MattoTodd
  • 14,467
  • 16
  • 59
  • 76
41
votes
7 answers

Convert mongodb return object to dictionary

I'm using the bottle framework together with mongoengine. I have an orders model : class OrderDetail(Option): orderDetailsQty = FloatField() def to_dict(self): return mongo_to_dict_helper(self) class Order(Document): userName…
mahesmohan
  • 784
  • 1
  • 13
  • 33
39
votes
5 answers

mongoengine - Ignore extra fields for schema validation

I am trying to query my database. Some records currently have extra fields that are not included in my model schema (by error, but I want to handle these cases). When I try to query the DB and transform the records into the schema, I get the…
Andrew
  • 1,355
  • 2
  • 13
  • 28
37
votes
4 answers

PyMongo vs MongoEngine for Django

For one of my projects I prefered using Django+Mongo. Why should I use MongoEngine, but not just PyMongo? What are advantages? Querying with PyMongo gives results that are allready objects, aren't they? So what is the purpose of MongoEngine?
megido
  • 4,135
  • 6
  • 29
  • 33
34
votes
1 answer

Sort using MongoEngine?

How do I sort the query objects in MongoEngine, like I would in a regular mongodb query? http://www.mongodb.org/display/DOCS/Sorting+and+Natural+Order
user235925
  • 838
  • 1
  • 8
  • 11
34
votes
2 answers

How to delete document from MongoDB using Mongoengine?

How to delete document from MongoDB using Mongoengine? I'veread the API reference here: http://docs.mongoengine.org/apireference.html but I can not understand what is: delete(**write_concern) Do you have any idea?
ehsan shirzadi
  • 4,709
  • 16
  • 69
  • 112
33
votes
9 answers

Mongoengine creation_time attribute in Document

I am trying to add a creation_time attribute to my documents. The following would be an example: import datetime class MyModel(mongoengine.Document): creation_date = mongo.DateTimeField() modified_date =…
josephmisiti
  • 9,862
  • 11
  • 56
  • 72
33
votes
1 answer

find() and findOne() in mongoengine

How can I do a quick find() or findOne() with mongoengine, I already have this but it does not seems to be the right way: Cars.objects()._collection.find_one({'model':2013})
Uuid
  • 2,506
  • 5
  • 28
  • 37
28
votes
5 answers

How to do "insert if not exist else update" with mongoengine?

I'm working with mongoengine in Django, this is my document defination: class Location(mongoengine.Document): user_id = mongoengine.IntField(required=True) point = mongoengine.GeoPointField(required=True) I want to do this: given a…
wong2
  • 34,358
  • 48
  • 134
  • 179
28
votes
1 answer

Django with Pluggable MongoDB Storage troubles

I'm trying to use django, and mongoengine to provide the storage backend only with GridFS. I still have a MySQL database. I'm running into a strange (to me) error when I'm deleting from the django admin and am wondering if I am doing something…
Aaron
  • 4,206
  • 3
  • 24
  • 28
26
votes
1 answer

Use MongoEngine and PyMongo together

I want to use MongoEngine for my next project. Now I'm wondering whether I could also use PyMongo directly in the same project. Just for the case that I need something very special that is not supported directly via mongoengine. Are there any doubts…
Thomas Kremmel
  • 14,575
  • 26
  • 108
  • 177
23
votes
2 answers

Implementing Bi-Directional relationships in MongoEngine

I'm building a Django application that uses MongoDB and MongoEngine to store data. To present a simplified version of my problem, say I want to have two classes: User and Page. Each page should associate itself with a user and each user a page. from…
23
votes
2 answers

multi document insert using mongoengine into mongodb

In my flask app I am using MongoeEgine. I am trying to insert multiple documents into my places collection in my MongoDB. My document class is defined as class places(db.Document): name = db.StringField(max_length=200, required=True) loc =…
user1340513
  • 247
  • 1
  • 2
  • 5
20
votes
5 answers

MongoDB using an OR clause in mongoengine

I'm using python's mongoengine to query MongoDB, and have loved it for the most part, but I'm having an issue with an advanced query. Here's my model class ContentItem(Document): account = ReferenceField(Account) creator =…
MattoTodd
  • 14,467
  • 16
  • 59
  • 76
18
votes
3 answers

MongoDb with FastAPI

I am playing around with FastAPI a bit and wanted to connect it to a MongoDB database. I however am confused which ODM to choose between motor which is async and mongoengine. Also, in the NoSQL example here they have created a new bucket and also…
Ayush Singh
  • 1,409
  • 3
  • 19
  • 31
1
2 3
99 100