fastapi-master/docs_src/sql_databases_peewee/sql_app/models.py

22 lines
465 B
Python
Raw Normal View History

2024-08-24 12:41:47 +08:00
import peewee
from .database import db
class User(peewee.Model):
email = peewee.CharField(unique=True, index=True)
hashed_password = peewee.CharField()
is_active = peewee.BooleanField(default=True)
class Meta:
database = db
class Item(peewee.Model):
title = peewee.CharField(index=True)
description = peewee.CharField(index=True)
owner = peewee.ForeignKeyField(User, backref="items")
class Meta:
database = db