2022-11-09 16:07:28 +00:00
|
|
|
package mongo
|
2022-11-09 12:19:56 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
|
|
)
|
|
|
|
|
|
|
|
// default values without ok
|
|
|
|
|
|
|
|
func bsonLookupBoolean(b *bson.Raw, key ...string) bool {
|
|
|
|
v, _ := b.Lookup(key...).BooleanOK()
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func bsonLookupStringValue(b *bson.Raw, key ...string) string {
|
|
|
|
v, _ := b.Lookup(key...).StringValueOK()
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func bsonLookupInt64(b *bson.Raw, key ...string) int64 {
|
|
|
|
v, _ := b.Lookup(key...).Int64OK()
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func bsonLookupTime(b *bson.Raw, key ...string) time.Time {
|
|
|
|
v, _ := b.Lookup(key...).TimeOK()
|
|
|
|
return v
|
|
|
|
}
|