Flask-RESTive extension to work with mongodb.
[](https://travis-ci.org/left-join/flask-restive-mongodb)
[](https://coveralls.io/github/left-join/flask-restive-mongodb?branch=master)
[](https://landscape.io/github/left-join/flask-restive-mongodb/master)
[](https://pypi.python.org/pypi/Flask-RESTive-MongoDB)
## Installation
```bash
pip install flask-restive-mongodb
```
## How to use
```python
from datetime import datetime
import mongoengine as me
from flask import Flask
from flask_restive import Api, StorageResource, UUIDSchema, fields
from marshmallow import pre_load
from flask_restive_mongodb import Model, Storage
app = Flask(__name__)
app.config['MONGODB_DATABASE_URI'] = 'mongodb://localhost/local'
def utc_time():
return datetime.utcnow().replace(microsecond=0)
class ClientSchema(UUIDSchema):
first_name = fields.String(required=True)
last_name = fields.String(required=True)
created_on = fields.DateTime(
required=True,
missing=lambda: utc_time().isoformat())
updated_on = fields.DateTime()
class Meta(UUIDSchema.Meta):
sortable_fields = ('id', 'created_on', 'updated_on')
default_sorting = ('-updated_on', '-created_on', 'id')
@pre_load(pass_many=False)
def set_updated_on(self, data):
# update time stamp on each create/update operation
data['updated_on'] = utc_time().isoformat()
return data
class ClientModel(Model):
id = me.fields.UUIDField(primary_key=True)
first_name = me.fields.StringField()
last_name = me.fields.StringField()
created_on = me.fields.DateTimeField()
updated_on = me.fields.DateTimeField()
class ClientStorage(Storage):
class Meta(Storage.Meta):
model_cls = ClientModel
primary_key_fields = ('id',)
class ClientResource(StorageResource):
data_schema_cls = ClientSchema
storage_cls = ClientStorage
api = Api(app, prefix='/api/v1', api_resources=[
(ClientResource, ('/clients', '/clients/<uuid:id>')),
])
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
```
Metadata
Release files for Flask-RESTive-MongoDB 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Flask-RESTive-MongoDB-0.0.1.tar.gz | 5.1 kB | Without provenance | Details for Flask-RESTive-MongoDB-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Flask_RESTive_MongoDB-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for Flask_RESTive_MongoDB-0.0.1-py3-none-any.whl |
Total release size: 13.3 kB
Release files / Flask-RESTive-MongoDB-0.0.1.tar.gz
| Download URL | Flask-RESTive-MongoDB-0.0.1.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b46d443f3fd9c6a0f1879602a0699bf5524ad2f888b865764924140b18d68f2b
|
|
BLAKE2b-256 checksum How to use checksums |
886523b07e4dd4cfca2fc268fa44293b4ef3512a9b0b20c618c61282def5314d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / Flask_RESTive_MongoDB-0.0.1-py3-none-any.whl
| Download URL | Flask_RESTive_MongoDB-0.0.1-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
48008bdc7174d35bfb2509c5a1c8d1d34e4ec86a8549a29f832b62ea027a2d82
|
|
BLAKE2b-256 checksum How to use checksums |
5da0e711e2dcde67c15f97aeb1aa18d3d10919b874c9a0176bf0cb6f4aad33f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for Flask-RESTive-MongoDB 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.