92e6c4fe1e
Extends DownloadSettings with 4 additional options: - Name: File name pattern for downloaded files (existed) - Disabled: Disables downloads - Originals: Only download files stored in "originals" folder - MediaRaw: Include RAW image files - MediaSidecar: Include metadata sidecar files (JSON, XMP, YAML)
28 lines
566 B
Go
28 lines
566 B
Go
package entity
|
|
|
|
import (
|
|
"github.com/jinzhu/gorm"
|
|
)
|
|
|
|
// Count returns the number of records for a given a model and key values.
|
|
func Count(m interface{}, keys []string, values []interface{}) int {
|
|
if m == nil || len(keys) != len(values) {
|
|
log.Debugf("entity: invalid parameters (count records)")
|
|
return -1
|
|
}
|
|
|
|
var count int
|
|
|
|
stmt := Db().Model(m)
|
|
|
|
for k := range keys {
|
|
stmt.Where("? = ?", gorm.Expr(keys[k]), values[k])
|
|
}
|
|
|
|
if err := stmt.Count(&count).Error; err != nil {
|
|
log.Debugf("entity: %s (count records)", err)
|
|
return -1
|
|
}
|
|
|
|
return count
|
|
}
|