Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a0a53f0477 | |||
| dffaa6326f |
+8
-3
@@ -161,6 +161,11 @@ type Filter struct {
|
|||||||
// Keys inside "and"/"or" are json tag names; the function resolves each to its
|
// Keys inside "and"/"or" are json tag names; the function resolves each to its
|
||||||
// full dotted BSON path using the target struct. Unknown keys are kept as-is.
|
// full dotted BSON path using the target struct. Unknown keys are kept as-is.
|
||||||
func FiltersFromFlatMap(flatMap map[string]interface{}, target interface{}) *Filters {
|
func FiltersFromFlatMap(flatMap map[string]interface{}, target interface{}) *Filters {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
fmt.Printf("Panic recovered FiltersFromFlatMap: %v\n", r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
filters := &Filters{
|
filters := &Filters{
|
||||||
And: make(map[string][]Filter),
|
And: make(map[string][]Filter),
|
||||||
Or: make(map[string][]Filter),
|
Or: make(map[string][]Filter),
|
||||||
@@ -180,12 +185,12 @@ func FiltersFromFlatMap(flatMap map[string]interface{}, target interface{}) *Fil
|
|||||||
}
|
}
|
||||||
for jsonKey, val := range m {
|
for jsonKey, val := range m {
|
||||||
bsonKey := resolve(jsonKey)
|
bsonKey := resolve(jsonKey)
|
||||||
items, ok := val.([]interface{})
|
//items, ok := val.([]interface{})
|
||||||
fmt.Println(jsonKey, val, ok, bsonKey)
|
fmt.Println(jsonKey, val, bsonKey)
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, item := range items {
|
for _, item := range val.([]interface{}) {
|
||||||
entry, ok := item.(map[string]interface{})
|
entry, ok := item.(map[string]interface{})
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user