Notas en frontend funcionando y pudiendo subir mas por sus endpoints
This commit is contained in:
@@ -26,8 +26,8 @@ if pssword is None:
|
||||
class BibliotecaModel(Base):
|
||||
__tablename__ = "bibliotecas"
|
||||
|
||||
id = Column(String, primary_key=True)
|
||||
nombre = Column(String, nullable=False)
|
||||
id = Column(String, primary_key=True, unique=True)
|
||||
nombre = Column(String, nullable=False, unique=True)
|
||||
descripcion = Column(String, default="")
|
||||
vector_dim = Column(Integer, nullable=False)
|
||||
embedder_info = Column(String, nullable=True) # Se puede guardar nombre de clase o config encriptada
|
||||
@@ -77,6 +77,11 @@ class BibliotecaRepo:
|
||||
self.session = conexion.get_session()
|
||||
|
||||
def add(self, biblioteca: Biblioteca) -> str:
|
||||
# Verificar si ya existe una biblioteca con el mismo nombre
|
||||
existente = self.session.query(BibliotecaModel).filter_by(nombre=biblioteca.nombre).first()
|
||||
if existente:
|
||||
raise ValueError(f"Ya existe una biblioteca con el nombre '{biblioteca.nombre}'")
|
||||
|
||||
data = BibliotecaMapper.to_dict(biblioteca)
|
||||
model = BibliotecaModel(**data)
|
||||
self.session.add(model)
|
||||
|
||||
Reference in New Issue
Block a user