add support for invoking and assigning scenes by name.
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-02-12 11:36:23 +01:00
parent 7471102413
commit cedd0d1d28
6 changed files with 61 additions and 16 deletions
+10
View File
@@ -29,6 +29,16 @@ func (r *SceneRepo) Find(ctx context.Context, id int) (*models.Scene, error) {
return r.populateOne(&scene)
}
func (r *SceneRepo) FindName(ctx context.Context, name string) (*models.Scene, error) {
var scene sceneRecord
err := r.DBX.GetContext(ctx, &scene, "SELECT * FROM scene WHERE name = ?", name)
if err != nil {
return nil, dbErr(err)
}
return r.populateOne(&scene)
}
func (r *SceneRepo) FetchAll(ctx context.Context) ([]models.Scene, error) {
scenes := make([]sceneRecord, 0, 8)
err := r.DBX.SelectContext(ctx, &scenes, "SELECT * FROM scene")