24 lines
438 B
Go
24 lines
438 B
Go
|
package leaf
|
||
|
|
||
|
import (
|
||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||
|
)
|
||
|
|
||
|
func ObjectIDFromHex(hex string) primitive.ObjectID {
|
||
|
id, err := primitive.ObjectIDFromHex(hex)
|
||
|
if err != nil {
|
||
|
return primitive.NilObjectID
|
||
|
}
|
||
|
|
||
|
return id
|
||
|
}
|
||
|
|
||
|
func ObjectIDFromHexSlice(hexSlice []string) []primitive.ObjectID {
|
||
|
ids := make([]primitive.ObjectID, len(hexSlice))
|
||
|
for i := range hexSlice {
|
||
|
ids[i] = ObjectIDFromHex(hexSlice[i])
|
||
|
}
|
||
|
|
||
|
return ids
|
||
|
}
|