1,819 questions
0
votes
0
answers
44
views
extended mapfield results in error when updating a doc - mongoengine
I am trying to write an enhanced field for mongoengine mapfield where it takes a defined enum and tracks the selection. Ideally, it locates and presents the enum when in python but saves the defined ...
1
vote
1
answer
264
views
Pymongo and Beanie Incompatibility issues
I'm trying to migrate from motor to pymongo's AsyncMongoClient.
After doing some upgrading/installing on pymongo I am having the below error when running this import from beanie import Document
...
0
votes
0
answers
43
views
Using pytest and mongoengine, data is created in the main database instead of a test one
I've installed these packages:
python -m pip install pytest pytest-django
And created a fixture:
# core/services/tests/fixtures/checkout.py
import pytest
from bson import ObjectId
from datetime ...
1
vote
0
answers
98
views
Get MongoDB telemetry using Open Telemetry auto instrumentation for flask?
My company runs a Flask API connected to MongoDB on atlas. Currently, we have minimal logging and metrics and rely solely on Altas to monitor DB usage. This month we realized the DB is being queried ...
1
vote
1
answer
43
views
MongoEngine library doesn't allow to use its BaseFields for persisting data
I started to use mongoengine library in order to read and write data from Mongo DB.
I found some strage behavior. The following class is defined in my codebase:
class CustomerRequest(BaseModel):
...
0
votes
0
answers
32
views
Query a Mongdb collection for documents which contain a dictionary of specific keys
How does one query a DictField to see if the keys contain a specific string. Originally the dictionary was used as it was easier to query or elements further in the tree. However, when expanding I ...
0
votes
0
answers
54
views
Consistent DateTime datatype when using both PyMongo and flask mongoengine
I am trying to maintain a consistent datatype for my datetimes in a Mongo collection, where some come from PyMongo, and others come from flask-mongoengine.
In Flask, the relevant model entry is:
...
0
votes
1
answer
29
views
Check if email in ListField of EmailField inside jinja2 template
Context:
I have a class as follows:
class DisplayArtwork(Document):
name = StringField(required=True)
email = EmailField(required=True)
country = StringField(required=True)
phone = ...
0
votes
1
answer
28
views
building a dynamic query for mongoengine
I am trying to interface with mongoengine and extract out posts based on different inputs. At first I was simply running a for loop with a modulatory query and running said query every time. However ...
1
vote
0
answers
33
views
mongoengine contains and exists in the same query
Is it possible to have a contains and exists call in the same query in mongodb, specifically mongoengine for python?
The data I need to parse is stored in a mapfield where I need to go into the keys ...
0
votes
1
answer
55
views
python & mongoengine, How do I map data to datetime?
I am trying to store temporal data in mongodb with the use of mongoengine. As the date of the data is a primary component, I thought it would be best to map the data to the date. However, when ...
2
votes
1
answer
131
views
How to make a field read-only in a `mongoengine` Document while allowing conditional updates?
I have a mongoengine document such as:
from mongoengine.document import Document
from mongoengine import StringField
class Class_A(Document):
field_a = StringField()
field_b = StringField()
...
0
votes
1
answer
50
views
Manual Migration of an existing DB to MongoEngine doesn't populate fields
I have an existing database of data that I want to use with MongoEngine. I updated the class as follows:
class World(Document):
user = ReferenceAttr(choices=["User"], required=True)
...
0
votes
1
answer
130
views
Mongoengine: Atomic [create or modification]
I have the following MongoDB document-class defined with mongoengine:
class Archive( mongoengine.Document ):
user_id = mongoengine.StringField()
transaction_ids = mongoengine.ListField(...
0
votes
0
answers
27
views
Find embedded document based on nested embedded document ID in MongoEngine
I have the following schema:
class Feature(EmbeddedDocument):
feature_name = StringField(required=True)
geometry = PolygonField(required=True)
id = ObjectIdField(required=True, default=...
0
votes
1
answer
296
views
UUID save issues with mongoengine and mongomock
I have production code that stores mongoengine.Documents with UUIDs like this:
class TestEntry(Document):
uuid_test = UUIDField(primary_key=True)
The regular code works as intended:
connect('...
1
vote
0
answers
40
views
Custom type for mongoengine field
I create DDD project in python and domain entities are mapped 1-1 to mongodb models.
I have the following class
class Experiment(Document, Entity):
id: ExperimentId = ExperimentId.Field(db_field='...
1
vote
0
answers
223
views
Cursor-based paging with a compound index in MongoDB and Python
The Python application I'm implementing works with the MongoDB database. I use the mongoengine module to connect and fetch data in my scripts (https://docs.mongoengine.org/).
My collection in the ...
0
votes
1
answer
55
views
MongoEngine upsert and append to ListField of IntChoiceField (append to list if record exists, create otherwise)
I have the following definition for an IntChoiceField:
from mongoengine import IntField
class IntChoiceField(IntField):
def __init__(self, min_value=None, max_value=None, choices: list = None, **...
0
votes
1
answer
94
views
In Mongoengine add a document and update a reference field in another document
I have two documents and I would like to link together through a reference Field using the _ID. The idea was to create the documents, save them to the database, take the _ID information and append it ...
0
votes
2
answers
399
views
Getting ReplicaSetNoPrimary error for M0 cluster when using Django with MongoEngine
I am using django with mongoengine. I am writing the following in the settings.py file:
from mongoengine import connect
URI = 'mongodb+srv://myusername:[email protected]/django?...
-2
votes
1
answer
54
views
Get weakly-referenced Error in Mongoengin
I use mongoengin in django app.
each document in mongo has metadata that is dict and in it there is image address with out base_url.
in django serializer I add base_url to it but it sometime get ...
0
votes
1
answer
71
views
Field in Document possible being a list and and object
I have some legacy MongoDB collection that has a particular field that can be null, a list ([]) and an object with a particular list of fields. I'm trying to implement the basic Document that allows ...
0
votes
0
answers
193
views
python mongoengine, to use or not to use no_dereference()?
Environment:
python: 3.8
mongodb: 3.4 (on docker container)
mongoengine: 0.20.0
One collection in mongodb, DEVICE, with 104 documents populated.
There are 9 ReferenceField attributes in the DEVICE ...
-1
votes
1
answer
202
views
How to set the maxidletimems for Mongoengine
The mongo library used in my project is Mongoengine
I often find the error 'pymongo. errors. CursorNotFound: Cursor not found' in the logs. After investigation, it was found that the mongo server ...
1
vote
1
answer
2k
views
Cannot use MongoClient after close
I've updated the pymongo and mongoengine packages, which are now 4.6.0 and 0.27.0, respectively.
After upgrading it On my Windows machine, I am trying to run celery tasks. In that celery task I have ...
1
vote
1
answer
92
views
How do relationships work on the mongoengine?
I'm new in mongoengine and I'm trying to relate two documments.
class Actor(Document):
name = StringField(required=True, unique=True)
movies = ListField()
class Movie(Document):
title = ...
0
votes
1
answer
299
views
mongoengine.errors.FieldDoesNotExist: The fields "{'__v'}" do not exist on the document "WorkflowExecutions"
I am working with python-flask and mongodb. Things was working fine suddenly I am getting the below error
mongoengine.errors.FieldDoesNotExist: The fields "{'__v'}" do not exist on the ...
0
votes
2
answers
188
views
Mongoengine Connection Failure
I am trying to run celery beat for my project, but it's giving me the following error.
The celery worker is running fine.
I am using Python 3.9
Using MongoDB: 6.0.11
raise ConnectionFailure(...
0
votes
1
answer
67
views
Load flask admin ListView even when a reference field is missing/deleted
I have made two API's with Flask Admin and mongoengine, This is how my document is in the first API.
class Score(db.Document):
score = StringField(required=True)
section= ReferenceField(...
2
votes
1
answer
58
views
mongoengine aggregate lookup on _id not working
Campaign Record
{
"_id": {
"$oid": "64eb81337f7d9f6e1107fc3a"
},
"_cls": "CampaignModel",
"campaignNumber": "CMPN-00005&...
0
votes
0
answers
214
views
Unable to use JWT with MongoDB (Django rest framework)
I am using mongoengine with Django rest framework as my backend and simple jwt to authenticate the user.
I am able to register/login the user successfully but when I use permission_classes of rest ...
0
votes
1
answer
56
views
How to update an item of embedded list field by index in Mongoengine?
I have a project using GraphQL and Mongoengine. To update a specific element of an embedded list field I do not want to get the whole list from the client instead I want to get a new value and the ...
0
votes
2
answers
328
views
How to realize tests on functions which are using mongoengine connection in Python?
I have Fast API with a Mongo Database
I try to realize my tests for some functions which need mongo connection
Here my collection users and its fields:
from mongoengine import Document, EmailField, ...
0
votes
2
answers
162
views
mongoengine: datetime object getting converted to string once saved using insert_one
I am trying to create a session_expiry time using Python and then inserting the session_expiry in mongo db using insert_one() method.
once the data in inserted in mongodb, while querying the mongo ...
1
vote
2
answers
258
views
MongoEngine - Adding reverse_delete_rule on ListField of ReferenceField Gives NotRegistered Error
I am using Flask + MongoEngine (0.22.1). I have 2 document types, where I don't have any circular dependency:
from mongoengine import Document, StringField, UUIDField, ListField
from ...
0
votes
1
answer
49
views
where is the collection name specified
app=Flask(__name__)
CORS(app)
app.config["MONGODB_SETTINGS"] = [
{
"db": "UPTeam",
"host": "10.64.127.94",
"port"...
0
votes
1
answer
558
views
How can I connect to DocumentDB in my local PC with python?
I'm using AWS DocumentDB service without TLS.
So, I can connect to DocumentDB without pem key.
Obviously I have easy access to DocumentDB from EC2, but I can't access it via Python code from my local ...
2
votes
0
answers
36
views
how can I customize the way pytest prints objects?
Is there a way I can control the way pytest creates string representations from objects?
specifically I am using mongoengine where the objects of type Document are just lazily outputed to console as &...
3
votes
1
answer
437
views
Most efficent way to bulk update Documents using MongoEngine
So, I have a Collection of documents (e.g. Person) structured in this way:
class Person(Document):
name = StringField(max_length=200, required=True)
nationality = StringField(max_length=200, ...
4
votes
1
answer
4k
views
MongoDB Compass: display binary type 3 guid
I have a python software that inserts uuids in a mongo database using this code:
class User(mongoengine.Document):
id = mongoengine.UUIDField(primary_key=True, required=True, default=lambda: str(...
1
vote
0
answers
36
views
Store image with mongoengine django
I am working on a project in which I have a Company template which contains a name, url and an image under a Mongoengine Document.
I would like to know how to store the image in the MEDIA folder ...
0
votes
3
answers
788
views
How do I upsert a document in MongoDB using mongoengine for Python?
I'm having a hard time struggling how to find out how to upsert in MongoDB using mongoengine.
My current inserting code looks like this:
for issue in data['issues']:
doc = Issue(
key=...
0
votes
1
answer
316
views
AttributeError: 'QuerySet' object has no attribute 'model'
I want to add documentation for the Django app
I use rest_framework_mongoengine, rest_framework
OpenAPI 3.0, drf-spectacular swagger
model :
from mongoengine import *
class Service(Document):
...
0
votes
0
answers
45
views
How to prevent repeated processing in Flask
I have a site in production using: Flask, Gunicorn, MongoEngine and I'm facing duplicate data processing error due to too many requests per second on certain routes.
Example code:
@app.route('/...
1
vote
0
answers
136
views
Getting an AttributeError using RetrieveUpdateDestroyAPIView
I am new to django and am using mongoengine. I am trying to create an employee database using DRF. All of the APIs are working well but whenever I am trying to fetch a single document which has been ...
1
vote
1
answer
128
views
In mongoengine how do you target a specific index in a list?
In mongoengine there are pull and unset commands. These allow you to remove values from a list if you provide them with a value to match against or the entire list. While that works without an issue ...
0
votes
2
answers
108
views
How to bulk transfer JSON via MongoEngine
Trying to send a lot of data to MongoDB through MongoEngine. I start with a DataFrame that I write to JSON like this:
result = df.to_json(orient="index")
parsed = json.loads(result)
...
0
votes
1
answer
71
views
Divide a MongoDB document into multiple documents based on Date Field using aggregation
I have a document on MongoDB that contains flight data records. This data goes back 4 years , and is mixed up in the flight_records array shown in the sample below. I want to split this document into ...
1
vote
0
answers
108
views
Decoding an image retrieved from mongodb to make it json serializable
I have some images saved in mongodb and I used mongoengine and flask to save them. Now I want to make it json serializable so I can send it to a react frontend. This is the code that I used to decode ...