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

Delete records from a collection of a specified DB

I am using mongoDB as my database, i am working on django projects and using mongoengine to connect with database. My question is if my default database in settings.py is DB1 and i want to delete all records of a collection which exists inside DB2…
Vikas Gautam
  • 239
  • 1
  • 4
  • 21
0
votes
1 answer

How to save a dictionary with key having value of type object

I am trying to save an object in mongodb using pymongo. I am calling an api which gives me and object and by iterating through object i am able to get fields and values. But problem is there may be some fields whose value is also an object and when…
Vikas Gautam
  • 239
  • 1
  • 4
  • 21
0
votes
1 answer

Save a file in a flask-wtf form to MongoDB's GridFS

I'm using the flask-user extension (https://flask-user.readthedocs.io/) along with the mongoengine adapter and flask-wtf to create an HTML form that'll accept several files (images, mp4). The goal is to directly store those files in MongoDB using…
Lucas P.
  • 125
  • 3
  • 12
0
votes
0 answers

what do referencefield store in mongoengine

What do ReferenceField stores. I mean does it store ObjectID (or in my case user_id, as it is primary_key for User model). How can I access all the attributes of User model through unit_user as we do with the Foreignkey in Django class…
Abhimanyu Singh
  • 369
  • 4
  • 20
0
votes
3 answers

how do I search null or none in mongoengine in my django work?

there is a field in my mongodb, i want to search the field, no matter this field is None or not, how do i search? for example:Robot.objects(data_set_id=None) i use this to search ,but get the error: bson.errors.InvalidId: 'None' is not a valid…
YI YU
  • 11
0
votes
1 answer

Create mongoengine connection wrapper to use in multiple modules

I'm creating a wrapper to solve all my connections with mongoengine, so I created a function that reads mongoDB configuration from a file and connects to it. Thee function looks like this: def connect_mongo_odm(config_file_location, db_name): if…
rafaelleru
  • 367
  • 1
  • 2
  • 19
0
votes
2 answers

Update all EmbeddedDocuments in EmbeddedDocumentListField if it matches criteria

I'm using mongoengine with a Document having a EmbeddedDocumentListField attribute. class Child(mongoengine.EmbeddedDocument): value = mongoengine.IntField(required=True) child_type = mongoengine.StringField(required=True, choices=["type1",…
julienc
  • 19,087
  • 17
  • 82
  • 82
0
votes
1 answer

How to access other class elements from ReferenceField in Mongoengine

class User(db.Document): email = db.StringField(required=True) first_name = db.StringField(max_length=50) ref = db.ReferenceField('Post') class Post(db.Document): title = db.StringField(max_length=120, required=True) tags =…
0
votes
1 answer

Flask, Pymongo and Mongoengine - ImportError: cannot import name 'app'

I'm running a flask application using mongoengine as a mongodb orm, on python 3. I'm configuring mongo connection in the general config file as follows: MONGODB_SETTINGS = { 'db': "dbname", 'host': "myhost", 'port': "27017", #…
magnoz
  • 1,939
  • 5
  • 22
  • 42
0
votes
0 answers

How to make this kind of aggregation in Mongo?

I have MongoDB 4.x with collection, which have documents like this image how to make agregation, that return only bot-field, where _id is X? I've tried to use $project: { _id: 0, bot: {$filter: { input: '$clusters.bots', as:…
0
votes
1 answer

Marshmallow serialization - a way to catch exceptions on a per field basis?

Is there a way to catch exceptions (that occur when accessing a property) on a per-field basis with marshmallow [1] ? I want to use marshmallow to serialize documents of a mongo db (mongoengine) database. With nested schemas, referenced objects are…
mfit
  • 807
  • 13
  • 28
0
votes
1 answer

Mongoengine: How to define custom collection name when allow_inheritance

I want to define a base Document to define some public filed and method. But I found the child Document can't define it's custom name when inheritance. such as: from mongoengine import * class BaseInfo(Document): account = StringField() …
C.shayv
  • 51
  • 5
0
votes
2 answers

Get the updated document after update_one

What parameter needs to pass for the MongoEngine update_one() to get the updated document in return? Currently, it is returning 0 or 1.
chetan tamboli
  • 161
  • 2
  • 13
0
votes
1 answer

mongoengine query to nested listfield

I made article system with python flask. To communicate with mongodb, use flask_mongoengine Here is my model. class SubComment(EmbeddedDocument): no = SequenceField() body = StringField() class Comment(EmbeddedDocument): no =…
Hide
  • 3,199
  • 7
  • 41
  • 83
0
votes
1 answer

MongoEngine Aggregation - pivot array to object

I am working on following MongoEngine classes class User(Document): username = EmailField(primary_key=True) name = StringField() class Asset(Document): users = ListField( ReferenceField("User") ) remote = MapField( DynamicField()…