Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
6c4af4006b
|
|||
8bf3a337cf
|
|||
16146494dc
|
@@ -3,19 +3,9 @@ package dataext
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type JsonTwoWayMarshal interface {
|
type JsonOpt[T any] struct {
|
||||||
json.Marshaler
|
|
||||||
json.Unmarshaler
|
|
||||||
}
|
|
||||||
|
|
||||||
type JsonOptType interface {
|
|
||||||
JsonTwoWayMarshal | ~string | ~bool | langext.NumberConstraint
|
|
||||||
}
|
|
||||||
|
|
||||||
type JsonOpt[T JsonOptType] struct {
|
|
||||||
isSet bool
|
isSet bool
|
||||||
value T
|
value T
|
||||||
}
|
}
|
||||||
@@ -26,10 +16,6 @@ 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 []byte("null"), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return json.Marshal(m.value)
|
return json.Marshal(m.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.420"
|
const GoextVersion = "0.0.423"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2024-03-23T18:01:41+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