generated from PenaSide/GolangTemplate
18 lines
354 B
Go
18 lines
354 B
Go
package bsontools
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
"strings"
|
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
)
|
|
|
|
func BuildCaseInsensitiveRegex(value string) bson.M {
|
|
return bson.M{"$regex": primitive.Regex{
|
|
Pattern: regexp.QuoteMeta(fmt.Sprintf(".*%s.*", regexp.QuoteMeta(strings.ToLower(value)))),
|
|
Options: "i",
|
|
}}
|
|
}
|