fix(module,store): allow querying on _id, _createdAt, _updatedAt attributes
This commit is contained in:
@ -3,10 +3,36 @@ package sqlite
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"forge.cadoles.com/arcad/edge/pkg/storage"
|
||||
"forge.cadoles.com/arcad/edge/pkg/storage/filter/sql"
|
||||
)
|
||||
|
||||
func transformOperator(operator string, invert bool, key string, value any, option *sql.Option) (string, any, error) {
|
||||
isDataAttr := true
|
||||
|
||||
switch key {
|
||||
case storage.DocumentAttrCreatedAt:
|
||||
key = "created_at"
|
||||
isDataAttr = false
|
||||
case storage.DocumentAttrUpdatedAt:
|
||||
key = "updated_at"
|
||||
isDataAttr = false
|
||||
case storage.DocumentAttrID:
|
||||
key = "id"
|
||||
isDataAttr = false
|
||||
}
|
||||
|
||||
if !isDataAttr {
|
||||
option = &sql.Option{
|
||||
PreparedParameter: option.PreparedParameter,
|
||||
KeyTransform: func(key string) string {
|
||||
return key
|
||||
},
|
||||
ValueTransform: option.ValueTransform,
|
||||
Transform: option.Transform,
|
||||
}
|
||||
}
|
||||
|
||||
switch operator {
|
||||
case sql.OpIn:
|
||||
return transformInOperator(key, value, option)
|
||||
|
Reference in New Issue
Block a user