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.
Questions tagged [mongoalchemy]
46 questions
1
vote
1 answer
How to display an array of objects using python flask and mongoalchemy
How to write an end point which will return a array of json objects for mongoalchemy
I am trying to do as shown below:
@authenticate_bp.route('/users',methods=['GET'])
def user_list():
users = [x.serialize for x in TokenBasedAuth.query.all()]
…

dhana lakshmi
- 847
- 1
- 12
- 29
1
vote
1 answer
where to specify connection string in mongoalchemy 0.21
I am working with mongoalchemy version 0.21 and unable to figure out where to specify mongodb connection string.
The last documentation available is for 0.14 and even in that, I couldn't figure out where one can specify MongoDB connection…

comiventor
- 3,922
- 5
- 50
- 77
1
vote
0 answers
Python Mongoalchemy Ref field at same class
Im stuck trying to solve this:
class User(db.Document):
date_add = db.CreatedField()
date_update = db.ModifiedField()
username = db.StringField()
password = db.StringField()
active = db.BoolField()
admin = db.BoolField()
…

Vanojx1
- 5,574
- 2
- 23
- 37
1
vote
2 answers
Array Definition Modelling in MongoAlchemy
I try to model my MongoAlchemy class in Flask. Here is my model:
{
"_id" : ObjectId("adfafdasfafag24t24t"),
"name" : "sth."
"surname" : "sth."
"address" : [
{
"city" : "Dublin"
"country" : "Ireland"
}
]
}
Here…

mathema
- 939
- 11
- 22
1
vote
1 answer
How to get current model object in Flask
We stored authenticated user (model of User) using
@app.route('/login', methods=['GET', 'POST'])
def login():
...
try:
current_user = User.query.filter(School_Login.mail == form_mail).first()
if user.mail == form_mail and…

mathema
- 939
- 11
- 22
1
vote
0 answers
MongoAlchemy Models with unrequired fields
I've got the below model with some fields that are not required. I'm trying to add a setter function to the model that accesses that field but it says the attribute doesn't exist. Even if there's no value in the DB, the model has the attribute,…

Scott
- 3,204
- 3
- 31
- 41
1
vote
1 answer
Which pagination is more efficient with MongoDB and Flask
I found here a nice template for a pagination. However, this example is done with
SQLlite.
It seems that it is possible to do pagination with flask-mongoengine,
flask-mongoalchemy
and pymongo.
I created a little code with PyMongo:
from pymongo…

user977828
- 7,259
- 16
- 66
- 117
1
vote
1 answer
Filtering by the value of an internal list using MongoAlchemy
I'm building a Flask app with Flask-MongoAlchemy, and I'm having trouble putting together a query.
I have the following document structure, for a 'Group' document:
{'name': 'some_name',
'participants': [
{'participant_id': 12345}
…

kronosapiens
- 1,333
- 1
- 10
- 19
1
vote
1 answer
Get field value within Flask-MongoAlchemy Document
I've looked at documentation, and have searched Google extensively, and haven't found a solution to my problem.
This is my readRSS function (note that 'get' is a method of Kenneth Reitz's requests module):
def readRSS(name, loc):
linkList = []
…

jbell730
- 21
- 5
1
vote
1 answer
Sophisticated string queries in MongoAlchemy
I'm learning MongoAlchemy, a layer on top of Python driver for MongoDB. Let's say there is a Python class, mapped from a MongoDB object like this:
from mongoalchemy.document import Document
from mongoalchemy.fields import *
class Person(Document):
…

Mirzhan Irkegulov
- 17,660
- 12
- 105
- 166
0
votes
1 answer
How to update DB when field changed in mongoalchemy.(flask)?
I am using flask-mongoalchemy to do a demo, and here is a question confused me for a while.
At first I create a class User
class Student(db.Document):
'''student info'''
name = db.StringField()
grade = db.IntField(required=False,…

McCree Feng
- 179
- 4
- 12
0
votes
1 answer
Unable to connect to mongodb atlas cluster using Flask mongoalchemy
I have used the below stackoverflow question link to try to connect to MongoDb atlas cluster using Flask MongoAlchemy but this does not seem to be working. Below is my code:>
from flask import Flask
from flask_mongoalchemy import MongoAlchemy
app =…

Subhayan Bhattacharya
- 5,407
- 7
- 42
- 60
0
votes
0 answers
How to fix," AttributeError: 'bool' object has no attribute 'quantity' " error in flask app
I'm trying to build a library management system in flask where in I want to issue/return book based on the username and serial number of the book.
I'm facing an Attribute Error. Please help me in solving it.
Here is the traceback error:
Traceback…

COCO.J
- 103
- 2
- 6
0
votes
0 answers
Convert MongoAlchemy model to PyMongo
I want to make a model with PyMongo. Below is a model using MongoAlchemy. How can I translate it to PyMongo?
from blue import app
from flask_mongoalchemy import MongoAlchemy
app.config['MONGOALCHEMY_DATABASE'] =…

Milan Mangar
- 41
- 1
- 9
0
votes
0 answers
Unable to query data from MongoAlchemy with Flask app
So I'm trying to learn Flask and MongoDB using MongoAlchemy and I'm running into an issue when trying to query my app for data, I'm not sure what I'm doing wrong. I've searched through the MongoAlchemy documentation and followed a few StackOverflow…

CGideon
- 143
- 2
- 15