add models
This commit is contained in:
parent
524b4763b7
commit
e28520a5fb
11
app/main.py
11
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 !"}
|
0
app/models/__init__.py
Normal file
0
app/models/__init__.py
Normal file
12
app/models/users.py
Normal file
12
app/models/users.py
Normal file
@ -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
|
0
app/routers/__init__.py
Normal file
0
app/routers/__init__.py
Normal file
@ -1,2 +1,3 @@
|
|||||||
fastapi
|
fastapi
|
||||||
uvicorn[standard]
|
uvicorn[standard]
|
||||||
|
pydantic-mongo
|
Loading…
x
Reference in New Issue
Block a user