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 flask graphene return wrong id?

when i print the id before returning, the code print the right value ( same with id in mongo ). but the client received a deferent id. my query code : def resolve_account(root, info, **kwargs): email = kwargs.get('email', None) password =…
Baltschun Ali
  • 376
  • 3
  • 12
0
votes
1 answer

How can I get a list of collections in a database using MongoEngine?

I'd like to know what call I can make from a python MongoEngine instance to get a list of collection names from my mongodb database? If I were using pymongo directly I could call db.list_collection_names(), but I can't find a similar call from…
0
votes
1 answer

How do I filter a reference field of an inherited mongoengine class

Let's say I have model A, Model B and Model C class ModelA(ModelB): data = mongoengine.ReferenceField() class ModelB(Document): customer = mongoengine.ReferenceField(ModelC) class ModelC(Document): name = mongoengine.stringField() I'm…
VIC3KING
  • 562
  • 1
  • 5
  • 11
0
votes
0 answers

How to retrieve the document that's just been added in MongoDB

I am using python and mongoengine for this project. And i am creating a restAPI. Since save() query in mongo inserts new or updates existing document. SearchRating(stars=4, comment='').save() // returns "None" on success This particular piece of…
TrickOrTreat
  • 821
  • 1
  • 9
  • 23
0
votes
1 answer

Filter by String Embedded Documents from the main document using MongoEngine - Python Flask

I am trying to filter embedded documents by String (LIKE Query SQL equivalent) from the parent document. Here's what I have now: def resolve_friend(root, info, **kwargs): phone = kwargs.get('phone', None) search_string =…
Nazmul
  • 500
  • 6
  • 17
0
votes
1 answer

mongoengine get method does not work for id with string value

I have specified mongoengine model class with _id field as a StringField: class Store(DynamicDocument): _id = StringField(primary_key=True, min_length=1) And now when I query document by _id field I get document properly: I can get it by pk…
egvo
  • 1,493
  • 18
  • 26
0
votes
1 answer

Best schema possible for a MongoDB database with embedded document containing lists

I'm currently discovering MongoDB and from what I understand, it appears there are several ways to create a schema according the use case. I have build a schema, with an embedded document but I'm really not sure it is the best model. On the one…
0
votes
1 answer

Does transaction.atomic works with mongoengine as well

I'm aware that we can manage db transaction to maintain transaction.atomic(), it works really well with SQL, just wanted to understand if I use mongoengine as ODM then will it work or if not what option do I have to maintain atomicity? Any help will…
Magnotta
  • 933
  • 11
  • 34
0
votes
1 answer

Can't use "gte" in mongoengine filter query

I have a MongoEngine Document class Student.. class Student(Document): db_id = StringField() name = StringField() score = IntField() deleted = BooleanField(default=False, required=True) I would like to query as…
Ananth.P
  • 445
  • 2
  • 8
0
votes
2 answers

mongoengine cross object links

I'll really new in mongo and mongoengine. I'll whant to create object like this: class Candle(Document): value = IntField() next = ReferenceField(Candle) prev = ReferenceField(Candle) For using like this: if Candle.value >…
0
votes
1 answer

MongoEngine specifying an ID

I'm having trouble getting MongoEngine to accept specific IDs. It seems absolutely determined to use (and only use) ObjectIds. I'm more than able to generate my own IDs in this instance, thanks. How can I get MongoEngine to play nice?
Noah McIlraith
  • 14,122
  • 7
  • 31
  • 35
0
votes
1 answer

ValueError: Cannot override primary key field

I have a base document class Feed from which RSS and Channels inherit. Here is the definition: class Feed(Document): meta_info = EmbeddedDocument(MetaInfo, default=MetaInfo, required=True) name = StringField() link = StringField() …
Sergey Ronin
  • 756
  • 7
  • 23
0
votes
1 answer

How to create unique and composite index on django model using mongo db

I'm using djangi and have created one model Person with few fields and want to implement indexing for efficient results. I've done indexing on SQL but with mongoengine I'm doing for first time. I'm stuck on how to implement unique index on the name…
Magnotta
  • 933
  • 11
  • 34
0
votes
1 answer

MongoEngine: if and how to sanitize search & data input?

I'm using MongoEngine in a project, and I was wondering if and how I need to sanitize user input when creating documents and searching them. For example, when I'm creating a document by providing data from resources like scraped RSS feeds (with…
Sergey Ronin
  • 756
  • 7
  • 23
0
votes
2 answers

Flask-restful How to `marshal_with()` data in reference_field of mongoengine?

I use Flask-restful and MongoEngine,I want to show the data in ReferenceField of my model in the JSON. I have this 2 model, RoomModel have a ReferenceField to UserModel: class RoomModel(Document): meta = {'allow_inheritance': True} …
ken
  • 2,426
  • 5
  • 43
  • 98