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
1 answer

Why is it so slow when update ListField in mongoengine?

It's too slow when I update a ListField with mongoengine.Here is an example class Post(Document): _id = StringField() txt = StringField() comments = ListField(EmbeddedDocumentField(Comment)) class Comment(EmbeddedDocument): comment…
DachuanZhao
  • 1,181
  • 3
  • 15
  • 34
0
votes
1 answer

Filter models on the basis of dictionary key

I am facing a problem while filtering a record from the database. In my database I have records which contain a dictfield. for eg region is a dictionary which contains other dictionaries like region = {'eastus': {'percentage_change': 0}, 'westus':…
Vikas Gautam
  • 239
  • 1
  • 4
  • 21
0
votes
0 answers

Using a SQL database and a NoSQL database

How do I connect Postgres and MongoDB at the same time in my Django project? I'm just clueless, and the MongoEngine documentation wasn't exactly helpful. Like what would I do in the settings, models, and views.py? Absolutely clueless. I mean, would…
user10973829
0
votes
1 answer

Update field if is null in mongoengine

I need to update a field of a Document if such field is None, but I don't want to overwrite it if such field has a value. Right now I'm doing the following: p = Person.objects(name="Foo").first() if p.address is None: p.update(set__address="Bar…
fabio.sang
  • 835
  • 8
  • 26
0
votes
1 answer

MognoDB - Aggregate count of arrays based on date

So I'm trying to make an aggregation query. I have documents that look like this: { "_id": ObjectId(), "value": [1,2], "date": ISODate("2016-06-02T03:02:00.000Z") }, { "_id": ObjectId(), "value": [1,2], "date":…
hrishikeshpaul
  • 459
  • 1
  • 11
  • 27
0
votes
0 answers

Python object.__getattribute__ not behaving correctly after override

I'm trying to replicate mongoengine functionality that lets you define field objects that can be used like normal python objects in the code. My idea is to create a FieldHolder class that contains the value and (de)serialization logic, and a…
rickyalbert
  • 2,552
  • 4
  • 21
  • 31
0
votes
1 answer

Finding the next and previous documents in a MongoEngine query

I would like to get the next and previous documents in a MongoEngine query which is ordered by a property. query = ImageModel \ .objects(dataset_id=dataset.id, deleted=False) \ .order_by('file_name') \ …
jsbroks
  • 530
  • 6
  • 15
0
votes
0 answers

Set schema to prevent nested values in mongodb in python

I have a collection which I want to insert documents in the way that each document can have as many Fields as it wants.But this structure has a constraint.Value of each field shouldn't be nested and by nested I mean something like dictionary , list…
0
votes
0 answers

MongoDB - Querying dollar prefixed fields

So I have a schema that looks like this: class Timeline(mongoengine.Document): # Who user = mongoengine.ReferenceField(User, required=True) # When date = mongoengine.DateTimeField(default=datetime.utcnow()) # What category…
0
votes
1 answer

marshmallow-mongoengine:Output dump value missing 'None' field

My project uses flask+mongoengine+marshmallow,When I used marshmallow to serialize the model, the returned value lacked field, and the missing field value was None.When using Django to serialize fields, the None value is still output model class…
0
votes
0 answers

How to include additional, unknown fields when loading data with marshmallow-mongoengine?

I am building a REST API on top of Flask and Connexion using marshmallow-mongoengine and MongoEngine to work with MongoDB. Problem: If my input data includes additional, unknown fields they are always excluded from the resulting object when loading…
mplaine
  • 15
  • 4
0
votes
1 answer

mongoengine dereferencing nested documents

I have a several comples mongo models. For example, a User that references a Role with some properties. Now when I retrieve users, I want the role property to be populated with those of the referenced role object, not the object id. from…
ahammond
  • 31
  • 6
0
votes
0 answers

how to filter objects on the basis of expression

I have a model in which there is a filed result which is dictfield, result has a field name. now my question is how can i use Model.objects.filter(result['name']='somename')? i want all objects in queryset which has result['name'] =…
Vikas Gautam
  • 239
  • 1
  • 4
  • 21
0
votes
1 answer

Upsert in mongoengine is not generating ObjectId

I am trying to execute an upsert function in mongoengine. That is, if a document is present, I want to update it with new values, and if it isn't present, I want to create and insert. I have list of objects. These objects can or cannot have…
hrishikeshpaul
  • 459
  • 1
  • 11
  • 27
0
votes
1 answer

drf mongoengine serializer imagefield none

I used Django restframework and mongoengine. Here is my model and serializer. [model.py] class Attachment(EmbeddedDocument): attachment_id = SequenceField() path = StringField() path_small = StringField() class Book(Document): …
Hide
  • 3,199
  • 7
  • 41
  • 83