Questions tagged [mongoalchemy]

MongoAlchemy is a layer on top of the Python MongoDB driver which adds client-side schema definitions, an easier to work with and programmatic query language, and a Document-Object mapper which allows python objects to be saved and loaded into the database in a type-safe way.

46 questions
0
votes
0 answers

How to shorten MongoDB ObjectId and use it on Flask Blueprint URL

I am looking for a way to shorten the ObjectID generated by the MongoDB and use it on Flask Blueprint. I has googling and got this tutorial for shorten ObjectID using base64 http://flask.pocoo.org/snippets/106/ But, base64 is too long for me. So, i…
adierebel
  • 11
  • 2
0
votes
1 answer

Update Existing Document : Mongo Alchemy

I need some help with MongoAlchemy. I'm trying to create a web application with python, flask, Mongo DM and Mongo Alchemy (as an object document mapper) and I'm struggling with updating existing documents. My problem is that I cannot update an…
alpha93
  • 1
  • 3
0
votes
0 answers

list array of objects using python flask

i have a payload as shown below which is stored in mongodb { "_id" : ObjectId("5865fbf5558b670ac091c81e"), "sensors" : [ { "sensorStatus" : "green ", "sensorName" : "s1" }, { …
dhana lakshmi
  • 847
  • 1
  • 12
  • 29
0
votes
0 answers

post request for lis of items using python flask

I am trying to do post request for below schema using flask-mongoAlchemy class Sensors(db.Document): sensorName = db.StringField() sensorStatus = db.StringField() class Camera(db.Document): cameraName = db.StringField() …
dhana lakshmi
  • 847
  • 1
  • 12
  • 29
0
votes
1 answer

MongoAlchemy: One of two different DocumentField's

Using MongoAlchemy, is it possible to have a DocumentField that can be one of two types? E.g: class A(Document): foo = StringField() class B(Document): bar = StringField() class C(Document): child = DocumentField(A or B) I thought of…
Jon G
  • 1,656
  • 3
  • 16
  • 42
0
votes
1 answer

MongoAlchemy regex return nothing

I'm testing MongoAlchemy for a project and I've to search user by name. I'm trying to make a regex but query result is always empty. I tried two methods : import re users = User.query.filter({"name":re.compile("/a/", re.IGNORECASE)}).all() And :…
amiceli
  • 437
  • 5
  • 11
  • 29
0
votes
1 answer

How to make a request for records where the value of the two fields match in mongoalchemy?

I have a model for mongoalchemy: class ImportProductReport(mongo.Document): target = mongo.IntField(default=0) processed = mongo.IntField(default=0) is_in_process_remove_offers = mongo.BoolField(default=False) is_old_offers_removed =…
Vasiliy
  • 1
  • 1
0
votes
1 answer

Why use MongoAlchemy when you could subclass a Python Dict?

A friend recently showed me that you can create an instance that is a subclass of dict in Python, and then use that instance to save, update, etc. Seems like you have more control, and it looks easier as well. class Marker(dict): def…
rjr862
  • 51
  • 5
0
votes
1 answer

Flask MongoAlchemy with multi hosts urls

I am new on MongoAlchemy. Currently i have pymongo which i only need use 1 URL to connect to mongolabs server mongodb://myusername:secretpassword@ds045801-a1.mongolab.com:45801,ds045808-a0.mongolab.com:45808/mydatabase_name While MongoAlchemy use…
Granit
  • 188
  • 1
  • 11
0
votes
1 answer

MongoAlchemy ObjectIdField resolution

If I have a Model that contains an ObjectIdField to another model, I would normally (django) use a property to create a getter and the reference would be transparent in usage. Like so: class Image(db.Document): name_full =…
Scott
  • 3,204
  • 3
  • 31
  • 41
0
votes
1 answer

Mongo alchemy select statements

I am using mongoalchemy for the first time and it is proving a great tool. When I try to select objects from my database I cant get the value of those objects. This is my code as below (I am using it with flask): class Password(db.Document): …
Adnan
  • 113
  • 1
  • 4
0
votes
1 answer

Validating for uniqueness in MongoAlchemy?

I am trying to ensure name uniqueness in a MongoAlchemy-backed model, and am uncertain how to go about it. My first attempt involved writing a wrap validator which checked for existing database entries with the same name and checked against them (to…
kronosapiens
  • 1,333
  • 1
  • 10
  • 19
0
votes
2 answers

Store a mongo_id on a MongoAlchemy Document?

Is it possible to store a mongo_id as an ObjectId object in a MongoAlchemy field? I've been able to store an ObjectId inside of a document I defined manually, but it seems as though I'm restricted to storing the string value of the id in the context…
kronosapiens
  • 1,333
  • 1
  • 10
  • 19
0
votes
1 answer

MongoAlchemy query embedded documents

I want to know how to use MongoAlchemy about embeded docment operation. But I havn't find any documents about these. Can anyone give me some helps? Here is demo code: #!/usr/bin/python # -*- coding: utf-8 -*- from flask import Flask from…
0
votes
1 answer

Settings TTL in MongoAlchemy's Index

Can I somehow specify expireAfterSeconds for collection's index in MongoAlchemy or I need to make hack like this: class TtlIndex(Index): def expires(self, seconds): self.expireAfterSeconds = seconds def ensure(self, collection): …
Marboni
  • 2,399
  • 3
  • 25
  • 42