From e28520a5fb00ac1035d621cece7d360ff87be9f0 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Tue, 10 Oct 2023 22:39:23 +0200 Subject: [PATCH] add models --- app/main.py | 11 +++++++++++ app/models/__init__.py | 0 app/models/users.py | 12 ++++++++++++ app/routers/__init__.py | 0 requierements.txt | 3 ++- 5 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 app/models/__init__.py create mode 100644 app/models/users.py create mode 100644 app/routers/__init__.py diff --git a/app/main.py b/app/main.py index e69de29..5dfe2c7 100644 --- a/app/main.py +++ b/app/main.py @@ -0,0 +1,11 @@ +from fastapi import FastAPI + +from .routers import users + +app = FastAPI() + +app.include_router(users.router) + +@app.get("/") +async def root(): + return {"message": "Hello World !"} \ No newline at end of file diff --git a/app/models/__init__.py b/app/models/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/models/users.py b/app/models/users.py new file mode 100644 index 0000000..b3da0b6 --- /dev/null +++ b/app/models/users.py @@ -0,0 +1,12 @@ +from pydantic import BaseModel +from pydantic_mongo import AbstractRepository, ObjectIdField + + +class Users(BaseModel): + id: ObjectIdField = None + username: str + + +class UsersRepository(AbstractRepository[Users]): + class Meta: + collection_name = users \ No newline at end of file diff --git a/app/routers/__init__.py b/app/routers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/requierements.txt b/requierements.txt index 8e0578a..13a6b2c 100644 --- a/requierements.txt +++ b/requierements.txt @@ -1,2 +1,3 @@ fastapi -uvicorn[standard] \ No newline at end of file +uvicorn[standard] +pydantic-mongo \ No newline at end of file