Bluemage/go/api/devices_exist.go

22 lines
521 B
Go
Raw Normal View History

package api
import (
"context"
"github.com/tigorlazuardi/bluemage/go/gen/models"
"github.com/tigorlazuardi/bluemage/go/pkg/errs"
"github.com/tigorlazuardi/bluemage/go/pkg/log"
)
func (api *API) DevicesExist(ctx context.Context, slug string) (exists bool, err error) {
ctx, coll := log.WithQueryCollector(ctx)
exists, err = models.DeviceExists(ctx, api.DB, slug)
if err != nil {
return exists, errs.Wrapw(err, "failed to check device existence",
"slug", slug,
"query", coll,
)
}
return exists, nil
}