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

Query nested documents inside an object in mongodb

I have developed a Python-Flask app using Mongoengine and mongodb as my database. I want to query my database and get all tickets of all users which have role of 'user'. here is my db modal for tickets and users: class…
0
votes
1 answer

Using MongoEngine to replace a value within a ListField

I'm creating a script using MongoEngine to update a collection. The update needs to modify a specific field within a ListField. Using raw pyMongo, the update would look like this: db.books.update({"authors": {"$elemMatch": {"$eq": "matt"}}},…
Nox Noctis
  • 114
  • 9
0
votes
1 answer

Creating Dynamic Models in MongoEngine

I'm new to MongoDB and MongoEngine and currently my documents are of below type : [ { "Question1": "How do you rate the whole restaurant", "Rating": [ "Poor", "Average", "Good" ], …
user3982364
0
votes
1 answer

make ID field required with MongoEngineObjectType

I use graphene with graphene-mongo. My graphql schema has a type similar to this: type Report { id:ID! name:String! } My graphene class for this type is class Product(MongoengineObjectType): class Meta: model = MongoProduct and…
Amelse Etomer
  • 1,253
  • 10
  • 28
0
votes
0 answers

Add attribute to object

I have an var containing all documents from mongoDB as an object. The way I set this is like this: questions = Questions.objects.order_by('-openDate') This works fine. When called, the objects show the attributes I expect. But now I want to add an…
0
votes
1 answer

How do I write all the records from a massive MongoDB collection into a csv file without taking up all RAM?

I have a collection in which I had uploaded the contents of a xml file that was 4GB. It had around 14000000 records. I need to write those records to a csv file. I was using the following code snippet thinking it will work fine as objects are…
jar
  • 2,646
  • 1
  • 22
  • 47
0
votes
1 answer

Mongoengine / MongoDB model filtering on basis of key presence in Dictionary field

I'm building a data-model using Mongoengine to store some metada for, in this case, email files. The very stripped down model, with only the field relevant for my issue, is: class Email(Document): headers = DictField() The headers dictionary…
Yonathan
  • 1,253
  • 1
  • 17
  • 29
0
votes
1 answer

Query embedded documents with mongo engine

so I'm using mongoengine to query embedded documents. schema: project class _StatusFields(mongoengine.EmbeddedDocument): start_time = mongoengine.DateTimeField() class _Status(mongoengine.EmbeddedDocument): start =…
hrishikeshpaul
  • 459
  • 1
  • 11
  • 27
0
votes
1 answer

Query to return all documents in which a field matches any element from a list in MongoEngine

I have two MongoDB collections. One is Users and another is Posts. In the user collection, each document stores a list of usernames that that particular user follows. For example, { 'username' : 'username', 'following' : ['user1', 'user2',…
0
votes
1 answer

How to grant access to two mongodb DB, to write records synchronously, after a celery task is triggered?

I have two databases (namely, test and celery). When a celery task is triggered, it will first update the "test" db with results and then update the "celery" db with success/failure message. I have secured these DBs with credentials and followed…
7wick
  • 411
  • 4
  • 17
0
votes
1 answer

Is there any module for handling database changes that leverages mongoengine to perform the migrations?

Like alembic and sqlalchemy. Is there any module for handling database changes that leverages mongoengine to perform the migrations ?
DachuanZhao
  • 1,181
  • 3
  • 15
  • 34
0
votes
1 answer

Create a Mongoengine FileField from a GridFs file_id or GridFSProxy

I have a string file_id of my file that is stored in mongodb in a fs collection (GridFs). I need to store the file as a mongoengine FileField in a Document, and then return the file to an endpoint ... so access the file's content, content_type…
RYS221
  • 60
  • 9
0
votes
2 answers

Can't authenticate using MongoEngine. PyMongo works. How do I get MongoEngine to authenticate?

I'm trying to authenticate for a MongoDB database using mongoengine.connect(). When I use pymongo.MongoClient() the code works perfectly, however mongoenine.connect() is throwing this error: pymongo.errors.OperationFailure: command createRole…
Craig
  • 55
  • 7
0
votes
2 answers

How to insert after a element in a ListField with mongoengine in python?

I want to add a element in a ListField.Here is my code: class Post(Document): _id = StringField() txt = StringField() comments = ListField(EmbeddedDocumentField(Comment)) class Comment(EmbeddedDocument): comment = StringField() …
DachuanZhao
  • 1,181
  • 3
  • 15
  • 34
0
votes
1 answer

updates to documents in mongoengine using positional operator updates only first element in the array

I'm using mongoengine and I have a collection Question. class Question(Document): id = StringField(primary_key=True) answers = EmbeddedDocumentListField(Answer) class Answer(EmbeddedDocument): id = StringField(primary_key=True) uid…
yogupta
  • 188
  • 1
  • 3
  • 9