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
0
votes
0 answers

The 'read_preference' option in find API in pymongo

I use mongoengine 0.15.0. I have a 'Report' model. In the model definition, there is a method statement: def check(self): existing_object = self.__class__._get_collection().find({ 'draft_id': self.draft_question_id, 'origin':…
CandyCrusher
  • 308
  • 1
  • 14
0
votes
0 answers

Access item in ListField/EmbeddedDocumentListField by using __raw__ in MongoEngine

I use mongoengine 0.15.0. In my Inventory Models, there is an ListField 'fruit' that contains EmbeddedDocumentField 'EmbedFruit'. Each EmbedFruit item has 'color' field. I want to access the first item in the ListField. Can I achieve it…
CandyCrusher
  • 308
  • 1
  • 14
0
votes
0 answers

Access ListField/EmbeddedDocumentListField by negative/minus index num

I use mongoengine 0.15.0. I have an embedded data structure containing an ListField. I want to access the last/latest item in the list. I am wondering if I can do like this to achieve: query_set = query_set.filter(fruit__-1__color=red) If there is…
CandyCrusher
  • 308
  • 1
  • 14
0
votes
0 answers

pymodm do not recognised the objects of a model

I have started using pymodm in my project (https://github.com/ypriverol/biocontainers-backend/blob/master/biocontainers/common/models.py). All CRUD operations work very well. However, when I try to retrieve the list of objects for a specific…
ypriverol
  • 585
  • 2
  • 8
  • 28
0
votes
1 answer

mongoengine get value on nested field

I have following list in mongodb. > db.article.find().pretty() { "_id" : ObjectId("5bebcfbb1b48d9974aac78ee"), "no" : 40, "subject" : "string", "content" : "string", "userid" : "string", "comments" : [ { …
Hide
  • 3,199
  • 7
  • 41
  • 83
0
votes
1 answer

marshmallow EmbeddedDocument doesn't work

I made a simple board api with flask-restplus and mongoengie. Also use marshmallow for serialize data. Below code is now I worked. [model] class Article(Document): no = SequenceField() subject = StringField(required=True) content =…
Hide
  • 3,199
  • 7
  • 41
  • 83
0
votes
0 answers

mongoengine ReferenceField's exact meaning?

I made a API system with flask-restplus and mongoengine Also I'm new at mongodb and mongoengine. I know that there is no foreign key in mongodb. But after read mongoengine's docs, I found some similar fields. ReferenceField is made fields that has…
Hide
  • 3,199
  • 7
  • 41
  • 83
0
votes
1 answer

Can mongoengine run raw query in python?

In pymongo,I can run raw query like this: conn = pymongo.MongoClient("mongodb://" + mongo_url) db = conn[db] db.authenticate(username,password) coll = db["coll_name"] coll.find(raw_query) How can I do that in mongoengine without creating a…
DachuanZhao
  • 1,181
  • 3
  • 15
  • 34
0
votes
1 answer

Update efficiently a ListField of Documents within a list of embedded document if and only if uniqueness within the innermost list is respected

I just came across a scenario that I don't know how to resolve with the existing structure of my documents. As shown below I can obviously resolve this problem with some refactoring but I am curious about how this could be resolve the most…
pgonz
  • 1
  • 1
  • 2
0
votes
1 answer

Mongoengine Error while adding data to the database

I have just started using mongoengine, I referred to the tutorials given at http://docs.mongoengine.org/tutorial.html I am getting an error when I am trying to add Post data to the database mongoengine.errors.ValidationError: ValidationError…
0
votes
1 answer

Sort a ListField containing ReferenceField (Mongoengine)

I have two classes declared as follows: from mongoengine import Document, fields, DynamicDocument class Booking(DynamicDocument): booking_id=fields.StringField(required=True) pickup_timestamp=fields.DateTimeField() class…
0
votes
0 answers

Issue retrieving document from MongoDB collection

I am learning Flask framework and creating a blog website using MongoDB as my back end db. I am perfectly able to save my data into a collection as a document, but I have trouble retrieving a saved document from my collection. I am using an Azure…
Prakazz
  • 421
  • 1
  • 8
  • 21
0
votes
1 answer

sql query in mongoengine

I have a document and an embedded document as shown below. And I would like to query the embedded document in mongoengine. In sql, this would be: SELECT A.Nom_PC, B.Intitule from Comptes as A, Vals as B WHERE B.Num = "some value" class…
salma
  • 13
  • 3
0
votes
1 answer

Python and MongoEngine, TypeError: Object of type ValidationError is not JSON serializable

What I'm trying to is building a REST API using python tornado, all were work well until I got this message when I post data to the API "TypeError: Object of type ValidationError is not JSON serializable". def post(self): try: data =…
Karam Haj
  • 1,080
  • 2
  • 9
  • 20
0
votes
1 answer

How to order coordinates with Mongoengine?

I'm working with Django and Mongoengine, I use GeoJson coordinates and I have to sort a coordinate list closest to the farthest, I have a starting point but I want to know if mongoengine can order those coordinates and what is the way to do it.