feat(locations): allowing AI to attach it to the image
This commit is contained in:
@@ -73,26 +73,15 @@ func (m LocationModel) Save(ctx context.Context, locations []model.Locations) ([
|
||||
return insertedLocation, err
|
||||
}
|
||||
|
||||
func (m LocationModel) SaveToImage(ctx context.Context, imageId uuid.UUID, locations []model.Locations) error {
|
||||
if len(locations) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
location, err := m.Save(ctx, locations)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: doesnt work if array is more than 1. BIG TODO
|
||||
|
||||
func (m LocationModel) SaveToImage(ctx context.Context, imageId uuid.UUID, locationId uuid.UUID) (model.ImageLocations, error) {
|
||||
insertImageLocationStmt := ImageLocations.
|
||||
INSERT(ImageLocations.ImageID, ImageLocations.LocationID).
|
||||
VALUES(imageId, location[0].ID)
|
||||
VALUES(imageId, locationId)
|
||||
|
||||
_, err = insertImageLocationStmt.ExecContext(ctx, m.dbPool)
|
||||
imageLocation := model.ImageLocations{}
|
||||
_, err := insertImageLocationStmt.ExecContext(ctx, m.dbPool)
|
||||
|
||||
return err
|
||||
return imageLocation, err
|
||||
}
|
||||
|
||||
func NewLocationModel(db *sql.DB) LocationModel {
|
||||
|
||||
Reference in New Issue
Block a user