photoprism/internal/entity/query/camera.go
Michael Mayer bc327016ad Metadata: Add Camera Make and Model updates via CLI & API #5663 #5656
Mirror the lens make/model editing surface for cameras: entity UpdateMakeModel/SaveForm, form validation, query, search, the GET/PUT /api/v1/cameras endpoints, and the cameras CLI command, plus a cameras ACL resource and scope.

Also tidy the lens surface for parity: self-validating SaveForm, empty make/model guard, X-Count search header, service-role grant, the empty-id/slug docs, and order cameras before lenses everywhere.
2026-06-15 09:25:44 +00:00

35 lines
606 B
Go

package query
import (
"github.com/photoprism/photoprism/internal/entity"
)
// FindCameraBySlug returns an existing entity if exists.
func FindCameraBySlug(slug string) *entity.Camera {
if slug == "" {
return nil
}
c := entity.Camera{}
if err := Db().Where("camera_slug = ?", slug).First(&c).Error; err != nil {
return nil
}
return &c
}
// FindCameraByID returns an existing entity if exists.
func FindCameraByID(id uint) *entity.Camera {
if id == 0 {
return nil
}
c := entity.Camera{}
if err := Db().Where("id = ?", id).First(&c).Error; err != nil {
return nil
}
return &c
}