Last active
May 26, 2020 21:06
-
-
Save gabbyprecious/05da2ef3088a9f86267957909a61ca33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastapi import APIRouter | |
from fastapi_sqlalchemy import db | |
from model import Follower as ModelFollower | |
from schema import FollowerCreate as SchemaFollower #Used to create validate Following and send to the model | |
from schema import Follower as Followers #Used to return Following | |
router = APIRouter() | |
@router.post("/follow", response_model=Followers) | |
async def follow(following: SchemaFollower): | |
Follower = ModelFollower(userId=following.userId, FollowerId=following.FollowerId) | |
db.session.add(Follower) | |
db.session.commit() | |
db.session.refresh(Follower) | |
return Follower |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment