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):
 | 
			
		||||
    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.commit()
 | 
			
		||||
    db.refresh(db_item)
 | 
			
		||||
 | 
			
		||||
@ -21,6 +21,7 @@ class IotEntity(Base):
 | 
			
		||||
    __tablename__ = "iot_entities"
 | 
			
		||||
 | 
			
		||||
    id = Column(Integer, primary_key=True, index=True)
 | 
			
		||||
    bluetooth_mac = Column(String)
 | 
			
		||||
    description = Column(String, index=True)
 | 
			
		||||
 | 
			
		||||
    authorized_users = relationship("User", secondary= 'user_iot_link')
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,7 @@ from pydantic import BaseModel
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class IotEntityBase(BaseModel):
 | 
			
		||||
    id: int
 | 
			
		||||
    bluetooth_mac: str
 | 
			
		||||
    description: str
 | 
			
		||||
 | 
			
		||||
class UserBase(BaseModel):
 | 
			
		||||
@ -18,10 +18,10 @@ class IotEntityCreate(IotEntityBase):
 | 
			
		||||
class UserCreate(UserBase):
 | 
			
		||||
    password: str
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class IotEntity(IotEntityBase):
 | 
			
		||||
    id: int
 | 
			
		||||
    description: str
 | 
			
		||||
    bluetooth_mac: str
 | 
			
		||||
    #authorized_users: List[User] = []
 | 
			
		||||
    class Config:
 | 
			
		||||
        orm_mode = True
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user