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

Add new attribute to existing document

How do I add an attribute to all documents in collection using mongoengine? I've tried several ways: for d in MyDocuments.objects: d.attr = 'test' d.save() This doesn't give any errors but it doesn't add new attribute to document. I've also…
NST
  • 724
  • 9
  • 20
0
votes
1 answer

Interrelated requests MySQL, analogue in MongoDB

Good day dear colleagues, I decided to move some projects from MySQL to MongoDB and faced several difficulties: For example there are two tables in MySQL: Users: CREATE TABLE `testdb`.`users` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY…
ololo
  • 108
  • 1
  • 7
0
votes
1 answer

Simple Mongoengine test gives error on Mac OSX

I'm new to MongoDB, but comfortable with Python. I installed MongoDB with brew install mongodb then ran mkdir -p /data/db then sudo chown -R `id -un` /data/db I installed mongoengine with conda install -c conda-forge mongoengine Then trying to…
Ben Lindsay
  • 1,686
  • 4
  • 23
  • 44
0
votes
1 answer

Mongoengine - Returning dates in a readable format

I'm querying mongo for a set of objects using mongoengine and I have to return the results as an array of JSON. This is how the object is defined: class OptimisedSummary(Document): date_from = DateTimeField() date_to = DateTimeField() …
magnoz
  • 1,939
  • 5
  • 22
  • 42
0
votes
3 answers

flask-marshmallow custom fields

I use flask-marshmallow and mongoengine. Also flask-restplus for my API server. Here is my api.py class BoardSchema(ma.Schema): class Meta: fields = ('no', 'title', 'body', 'tags', 'created_at', 'views') board_schema =…
Hide
  • 3,199
  • 7
  • 41
  • 83
0
votes
1 answer

Sum or Difference operation of two keys in document using Mongoengine

I have defined a model like Class Orders(Document): orderAmount = fields.FloatField() cashbackAmount = fields.FloatField() meta = {'strict': False} I want to get all orders where (orderAmount - cashbackAmount value > 500). I am using…
Kartikeya Mishra
  • 118
  • 2
  • 10
0
votes
0 answers

unable to except ValueError thrown by mongoengine

I'm trying to catch a ValueError that occurs due to the skip parameter equal to a negative number. For example, try: MyModel.objects.skip(-1) except ValueError as error: print(error) does not do anything. It doesn't error out with ANY…
Albert
  • 2,146
  • 10
  • 32
  • 54
0
votes
1 answer

Flask-DebugToolbar not working with mongoDB

I am tying to use Flask-MongoEngine which is working fine, but I am trying to get the debug toolbar to work and when I follow the documentation I get a traceback shown below. I am able to run the normal flask debug toolbar fine but since I am using…
Max Powers
  • 1,119
  • 4
  • 23
  • 54
0
votes
1 answer

sum by hours/days/month based on timestamp in mongoengine/pymongo

At first - I am a beginner with mongodb. So i have next probleb. I am using such a model as below with mongoengine: class Stats(Document): Name = StringField(max_length=250) timestamp = LongField(default=mktime(datetime.now().timetuple())) …
0
votes
1 answer

Django: Serializers filtering out undeclared fields

Here is my MSV: models.py import mongoengine class PersonAddressModel(mongoengine.DynamicEmbeddedDocument): country = mongoengine.fields.StringField() town = mongoengine.fields.StringField() class…
GoBear
  • 518
  • 1
  • 5
  • 19
0
votes
2 answers

Flask-mongoengine: Unable to import MongoEngine From flask-mongoengine

I must be missing something but I look around and couldn't find reference to this issue. I have the very basic code, as seen in flask-mongoengine documentation. test.py: from flask import Flask from flask_mongoengine import MongoEngine When I run…
0
votes
0 answers

How to reference to 'self' in MongoEngine

I am trying to make simple rating application, where I am using MongoDB via MongoEngine ODM. I have some troubles with understanding the ReferencingField(). I am tracking changes of User() documents with fields date_created and date_modified in User…
LauriTK
  • 1
  • 2
0
votes
0 answers

Getting application errors on Azure I dont get locally

I am developing a Flask/MongoDB application Im deploying on Azure. Locally, I am in the process of creating my models and testing my database connection. I am using Flask-MongoEngine to manage my DB connection. This is a sample of code that works…
0
votes
1 answer

Query an EmbeddedDocumentFieldList by MongoEngine use or operate

I am trying to query something in EmbeddedDocumentFieldList field, and I want use or operate into conditions. schema as blew: class EmbeddedDoc(EmbeddedDocument): name = StringField() class ParentDoc(Document): name = StringField(): …
Scott
  • 1
  • 3
0
votes
0 answers

How to write a unit test for when "During handling of the above exception, another exception occurred"

Unique index constraint in mongoengine throws this exception when I'm trying to save an object with the same id: |2018-06-28 14:23:28.084| [DEBUG] (rec.exchange.base|26): Processing exchange data Traceback (most recent call last): File…
NST
  • 724
  • 9
  • 20