sql_app: db: IotEntity added bluetooth field
Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
parent
fe3a193a4f
commit
9a7e6a288f
@ -36,7 +36,8 @@ def get_iot_entities(db: Session, skip: int = 0, limit: int = 100):
|
|||||||
|
|
||||||
|
|
||||||
def create_iot_entity(db: Session, iot_entity: schemas.IotEntityCreate):
|
def create_iot_entity(db: Session, iot_entity: schemas.IotEntityCreate):
|
||||||
db_item = models.IotEntity(id=iot_entity.id, description=iot_entity.description)
|
db_item = models.IotEntity(bluetooth_mac=iot_entity.bluetooth_mac,
|
||||||
|
description=iot_entity.description)
|
||||||
db.add(db_item)
|
db.add(db_item)
|
||||||
db.commit()
|
db.commit()
|
||||||
db.refresh(db_item)
|
db.refresh(db_item)
|
||||||
|
@ -21,6 +21,7 @@ class IotEntity(Base):
|
|||||||
__tablename__ = "iot_entities"
|
__tablename__ = "iot_entities"
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True, index=True)
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
|
bluetooth_mac = Column(String)
|
||||||
description = Column(String, index=True)
|
description = Column(String, index=True)
|
||||||
|
|
||||||
authorized_users = relationship("User", secondary= 'user_iot_link')
|
authorized_users = relationship("User", secondary= 'user_iot_link')
|
||||||
|
@ -4,7 +4,7 @@ from pydantic import BaseModel
|
|||||||
|
|
||||||
|
|
||||||
class IotEntityBase(BaseModel):
|
class IotEntityBase(BaseModel):
|
||||||
id: int
|
bluetooth_mac: str
|
||||||
description: str
|
description: str
|
||||||
|
|
||||||
class UserBase(BaseModel):
|
class UserBase(BaseModel):
|
||||||
@ -18,10 +18,10 @@ class IotEntityCreate(IotEntityBase):
|
|||||||
class UserCreate(UserBase):
|
class UserCreate(UserBase):
|
||||||
password: str
|
password: str
|
||||||
|
|
||||||
|
|
||||||
class IotEntity(IotEntityBase):
|
class IotEntity(IotEntityBase):
|
||||||
id: int
|
id: int
|
||||||
description: str
|
description: str
|
||||||
|
bluetooth_mac: str
|
||||||
#authorized_users: List[User] = []
|
#authorized_users: List[User] = []
|
||||||
class Config:
|
class Config:
|
||||||
orm_mode = True
|
orm_mode = True
|
||||||
|
Loading…
Reference in New Issue
Block a user