fix(module,store): allow querying on _id, _createdAt, _updatedAt attributes

This commit is contained in:
2023-02-21 15:05:01 +01:00
parent f01b1ef3b2
commit b9f985ab0c
5 changed files with 284 additions and 7 deletions

View File

@ -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)