photoprism/internal/query/file_syncs.go
Michael Mayer e3bb8b19dd Routing: Prefix frontend UI routes with /library #840 #2466
Also improves migrations and updates the db schema docs.

Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-10-15 21:54:11 +02:00

33 lines
623 B
Go

package query
import (
"github.com/photoprism/photoprism/internal/entity"
)
// FileSyncs returns a list of FileSync entities for a given account and status.
func FileSyncs(accountId uint, status string, limit int) (result []entity.FileSync, err error) {
s := Db().Where(&entity.FileSync{})
if accountId > 0 {
s = s.Where("service_id = ?", accountId)
}
if status != "" {
s = s.Where("status = ?", status)
}
s = s.Order("remote_name ASC")
if limit > 0 {
s = s.Limit(limit).Offset(0)
}
s = s.Preload("File")
if err := s.Find(&result).Error; err != nil {
return result, err
}
return result, nil
}