FastApi Gino ViewSets
Project description
Inspired by Django Rest Framework
Github: https://github.com/basalex/fastapi_gino_viewsets
Examples of usage:
Create your model and migrate database
class User(db.Model):
__tablename__ = 'users'
id = db.Column(db.Integer(), primary_key=True)
username = db.Column(db.String(255), nullable=False, unique=True)
email = db.Column(db.EmailType, nullable=False, unique=True)
age = db.Column(db.Integer(), nullable=True)
Then, you would want to use MainRouter class
from fastapi_gino_viewsets import MainRouter
from fastapi_gino_viewsets import Viewset
router = MainRouter()
@router.add_view('/user)
class UserViewSet(ViewSet):
model = User
Available Mixin and ViewSet classes
- AggregationMixin - Requires output_schema -> retrieve_aggregated_data
get_query[sync, async] - required to be manually implemented
filter_query - override to change filters behaviour
- ListMixin - Used when you want to get a list of objects, main method -> retrieve_list methods
base_list_schema -> override base class for output schema
retrieve_list - it’s not recommended to be overridden, probably you just don’t need to use the mixin
get_query[sync, async] - override to change default behaviour
filter_query - override to change filters behaviour
sort_query - override to change sort behaviour
total - override to change total count calculation
paginate - override to change paginate behaviour
prepare_data_hook - override for manipulating data after query execution
RetrieveModelMixin - Get single object by id -> retrieve method
UpdateModelMixin - Update using PUT http -> update method
UpdateModelMixin - Update using PATCH http -> update_partial method
DeleteModelMixin - Delete object by id -> delete method
ReadOnlyViewset - Provides retrieve and retrieve_list methods
Viewset - Prodiveds all methods from all mixins, but AggregationMixin
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fastapi-gino-viewsets-0.1.0b6.tar.gz
.
File metadata
- Download URL: fastapi-gino-viewsets-0.1.0b6.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d637bbae30600d6c137aaf59a5b068aaae387b26c0b9a6c413415b3999e9cbad |
|
MD5 | 04706e32155cc9c64d705461f99a3de9 |
|
BLAKE2b-256 | 8c08f2b5ce7a10eeba543c561517790f6523598b6f6532a27dca55fbddf9d222 |
File details
Details for the file fastapi_gino_viewsets-0.1.0b6-py3-none-any.whl
.
File metadata
- Download URL: fastapi_gino_viewsets-0.1.0b6-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc9981fb2bb2b649ca1020b2dc0d924d823280a177636ee02584832e9dd3984f |
|
MD5 | 4b3d389be041e096a1ddf6c12887e6e9 |
|
BLAKE2b-256 | 3084dd10f7afaff070a825ae1cd1f28fb15435eb0fab729d7b4fc8ba29ae7a75 |