add file size

This commit is contained in:
Simon Ding
2024-07-15 15:46:02 +08:00
parent f0b334ebcd
commit 688e51dbb1
10 changed files with 253 additions and 2 deletions

View File

@@ -23,6 +23,8 @@ const (
FieldDate = "date"
// FieldTargetDir holds the string denoting the target_dir field in the database.
FieldTargetDir = "target_dir"
// FieldSize holds the string denoting the size field in the database.
FieldSize = "size"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// FieldSaved holds the string denoting the saved field in the database.
@@ -39,6 +41,7 @@ var Columns = []string{
FieldSourceTitle,
FieldDate,
FieldTargetDir,
FieldSize,
FieldStatus,
FieldSaved,
}
@@ -53,6 +56,11 @@ func ValidColumn(column string) bool {
return false
}
var (
// DefaultSize holds the default value on creation for the "size" field.
DefaultSize int
)
// Status defines the type for the "status" enum field.
type Status string
@@ -111,6 +119,11 @@ func ByTargetDir(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTargetDir, opts...).ToFunc()
}
// BySize orders the results by the size field.
func BySize(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSize, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()