Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
6c4af4006b
|
|||
8bf3a337cf
|
|||
16146494dc
|
|||
b0e443ad99
|
@@ -5,12 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type JsonTwoWayMarshal interface {
|
type JsonOpt[T any] struct {
|
||||||
json.Marshaler
|
|
||||||
json.Unmarshaler
|
|
||||||
}
|
|
||||||
|
|
||||||
type JsonOpt[T JsonTwoWayMarshal] struct {
|
|
||||||
isSet bool
|
isSet bool
|
||||||
value T
|
value T
|
||||||
}
|
}
|
||||||
@@ -21,11 +16,7 @@ func (m JsonOpt[T]) MarshalJSON() ([]byte, error) {
|
|||||||
return []byte("null"), nil // actually this would be undefined - but undefined is not valid JSON
|
return []byte("null"), nil // actually this would be undefined - but undefined is not valid JSON
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.value == nil {
|
return json.Marshal(m.value)
|
||||||
return []byte("null"), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return m.MarshalJSON()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON sets *m to a copy of data.
|
// UnmarshalJSON sets *m to a copy of data.
|
||||||
@@ -34,7 +25,7 @@ func (m *JsonOpt[T]) UnmarshalJSON(data []byte) error {
|
|||||||
return errors.New("JsonOpt: UnmarshalJSON on nil pointer")
|
return errors.New("JsonOpt: UnmarshalJSON on nil pointer")
|
||||||
}
|
}
|
||||||
|
|
||||||
return m.value.UnmarshalJSON(data)
|
return json.Unmarshal(data, &m.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m JsonOpt[T]) IsSet() bool {
|
func (m JsonOpt[T]) IsSet() bool {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.419"
|
const GoextVersion = "0.0.423"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2024-03-23T17:49:56+0100"
|
const GoextVersionTimestamp = "2024-03-24T15:25:52+0100"
|
||||||
|
@@ -171,7 +171,7 @@ func createPaginationPipeline[TData any](coll *Coll[TData], token ct.CursorToken
|
|||||||
bson.M{*fieldSecondary: bson.M{"$gt": valueSecondary}},
|
bson.M{*fieldSecondary: bson.M{"$gt": valueSecondary}},
|
||||||
}})
|
}})
|
||||||
|
|
||||||
sort = append(sort, bson.E{Key: fieldPrimary, Value: +1})
|
sort = append(sort, bson.E{Key: *fieldSecondary, Value: +1})
|
||||||
|
|
||||||
} else if *sortSecondary == ct.SortDESC {
|
} else if *sortSecondary == ct.SortDESC {
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ func createPaginationPipeline[TData any](coll *Coll[TData], token ct.CursorToken
|
|||||||
bson.M{*fieldSecondary: bson.M{"$lt": valueSecondary}},
|
bson.M{*fieldSecondary: bson.M{"$lt": valueSecondary}},
|
||||||
}})
|
}})
|
||||||
|
|
||||||
sort = append(sort, bson.E{Key: fieldPrimary, Value: -1})
|
sort = append(sort, bson.E{Key: *fieldSecondary, Value: -1})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user