@@ -19,26 +19,30 @@ import (
1919 "go.mongodb.org/mongo-driver/bson/bsontype"
2020)
2121
22- func Id (value any ) bson.D {
23- return bson.D {bson.E {Key : IdOp , Value : value }}
24- }
25-
2622func All [T any ](values ... T ) bson.D {
2723 return bson.D {bson.E {Key : AllOp , Value : values }}
2824}
2925
30- func ElemMatch ( key string , cond any ) bson.D {
31- return bson.D {bson.E {Key : key , Value : bson. D {{ Key : ElemMatchOp , Value : cond }} }}
26+ func And ( conditions ... any ) bson.D {
27+ return bson.D {bson.E {Key : AndOp , Value : conditions }}
3228}
3329
34- func Size (key string , value int ) bson.D {
35- return bson.D {bson.E {Key : key , Value : bson.D {{Key : SizeOp , Value : value }}}}
30+ func ElemMatch (key string , cond any ) bson.D {
31+ return bson.D {bson.E {Key : key , Value : bson.D {{Key : ElemMatchOp , Value : cond }}}}
3632}
3733
3834func Eq (key string , value any ) bson.D {
3935 return bson.D {bson.E {Key : key , Value : bson.D {{Key : EqOp , Value : value }}}}
4036}
4137
38+ func Exists (key string , value bool ) bson.D {
39+ return bson.D {bson.E {Key : key , Value : bson.D {{Key : ExistsOp , Value : value }}}}
40+ }
41+
42+ func Expr (value any ) bson.D {
43+ return bson.D {bson.E {Key : ExprOp , Value : value }}
44+ }
45+
4246func Gt (key string , value any ) bson.D {
4347 return bson.D {bson.E {Key : key , Value : bson.D {{Key : GtOp , Value : value }}}}
4448}
@@ -47,12 +51,16 @@ func Gte(key string, value any) bson.D {
4751 return bson.D {bson.E {Key : key , Value : bson.D {{Key : GteOp , Value : value }}}}
4852}
4953
54+ func Id (value any ) bson.D {
55+ return bson.D {bson.E {Key : IdOp , Value : value }}
56+ }
57+
5058func In [T any ](key string , values ... T ) bson.D {
5159 return bson.D {bson.E {Key : key , Value : bson.D {{Key : InOp , Value : values }}}}
5260}
5361
54- func NIn [ T any ]( key string , values ... T ) bson.D {
55- return bson.D {bson.E {Key : key , Value : bson. D {{ Key : NinOp , Value : values }} }}
62+ func JsonSchema ( value any ) bson.D {
63+ return bson.D {bson.E {Key : JsonSchemaOp , Value : value }}
5664}
5765
5866func Lt (key string , value any ) bson.D {
@@ -63,48 +71,48 @@ func Lte(key string, value any) bson.D {
6371 return bson.D {bson.E {Key : key , Value : bson.D {{Key : LteOp , Value : value }}}}
6472}
6573
66- func Ne (key string , value any ) bson.D {
67- return bson.D {bson.E {Key : key , Value : bson.D {{Key : NeOp , Value : value }}}}
74+ func Mod (key string , divisor any , remainder int ) bson.D {
75+ return bson.D {bson.E {Key : key , Value : bson.D {{Key : ModOp , Value : bson. A { divisor , remainder } }}}}
6876}
6977
70- func Exists (key string , value bool ) bson.D {
71- return bson.D {bson.E {Key : key , Value : bson.D {{Key : ExistsOp , Value : value }}}}
78+ func NIn [ T any ] (key string , values ... T ) bson.D {
79+ return bson.D {bson.E {Key : key , Value : bson.D {{Key : NinOp , Value : values }}}}
7280}
7381
74- func Type (key string , value bsontype. Type ) bson.D {
75- return bson.D {bson.E {Key : key , Value : bson.D {{Key : TypeOp , Value : value }}}}
82+ func Ne (key string , value any ) bson.D {
83+ return bson.D {bson.E {Key : key , Value : bson.D {{Key : NeOp , Value : value }}}}
7684}
7785
78- func TypeAlias ( key string , value string ) bson.D {
79- return bson.D {bson.E {Key : key , Value : bson. D {{ Key : TypeOp , Value : value }} }}
86+ func Nor ( conditions ... any ) bson.D {
87+ return bson.D {bson.E {Key : NorOp , Value : conditions }}
8088}
8189
82- func TypeArray ( key string , values ... bsontype. Type ) bson.D {
83- return bson.D {bson.E {Key : key , Value : bson. D {{ Key : TypeOp , Value : values }} }}
90+ func Not ( cond any ) bson.D {
91+ return bson.D {bson.E {Key : NotOp , Value : cond }}
8492}
8593
86- func TypeArrayAlias ( key string , values ... string ) bson.D {
87- return bson.D {bson.E {Key : key , Value : bson. D {{ Key : TypeOp , Value : values }} }}
94+ func Or ( conditions ... any ) bson.D {
95+ return bson.D {bson.E {Key : OrOp , Value : conditions }}
8896}
8997
90- func Expr ( value any ) bson.D {
91- return bson.D {bson.E {Key : ExprOp , Value : value }}
98+ func Regex ( key , value string ) bson.D {
99+ return bson.D {bson.E {Key : key , Value : bson. D {{ Key : RegexOp , Value : value }} }}
92100}
93101
94- func JsonSchema ( value any ) bson.D {
95- return bson.D {bson.E {Key : JsonSchemaOp , Value : value }}
102+ func RegexOptions ( key , value , options string ) bson.D {
103+ return bson.D {bson.E {Key : key , Value : bson. D {{ Key : RegexOp , Value : value }, { Key : OptionsOp , Value : options }} }}
96104}
97105
98- func Mod (key string , divisor any , remainder int ) bson.D {
99- return bson.D {bson.E {Key : key , Value : bson.D {{Key : ModOp , Value : bson. A { divisor , remainder } }}}}
106+ func Size (key string , value int ) bson.D {
107+ return bson.D {bson.E {Key : key , Value : bson.D {{Key : SizeOp , Value : value }}}}
100108}
101109
102- func Regex (key , value string ) bson.D {
103- return bson.D {bson.E {Key : key , Value : bson.D {{Key : RegexOp , Value : value }}}}
110+ func Slice (key string , number int ) bson.D {
111+ return bson.D {bson.E {Key : key , Value : bson.D {{Key : SliceOp , Value : number }}}}
104112}
105113
106- func RegexOptions (key , value , options string ) bson.D {
107- return bson.D {bson.E {Key : key , Value : bson.D {{Key : RegexOp , Value : value }, { Key : OptionsOp , Value : options }}}}
114+ func SliceRanger (key string , start , end int ) bson.D {
115+ return bson.D {bson.E {Key : key , Value : bson.D {{Key : SliceOp , Value : [] int { start , end } }}}}
108116}
109117
110118func Text (search string , opt * TextOptions ) bson.D {
@@ -124,30 +132,22 @@ func Text(search string, opt *TextOptions) bson.D {
124132 return bson.D {bson.E {Key : TextOp , Value : d }}
125133}
126134
127- func Where (value string ) bson.D {
128- return bson.D {bson.E {Key : WhereOp , Value : value }}
129- }
130-
131- func And (conditions ... any ) bson.D {
132- return bson.D {bson.E {Key : AndOp , Value : conditions }}
133- }
134-
135- func Not (cond any ) bson.D {
136- return bson.D {bson.E {Key : NotOp , Value : cond }}
135+ func Type (key string , value bsontype.Type ) bson.D {
136+ return bson.D {bson.E {Key : key , Value : bson.D {{Key : TypeOp , Value : value }}}}
137137}
138138
139- func Nor ( conditions ... any ) bson.D {
140- return bson.D {bson.E {Key : NorOp , Value : conditions }}
139+ func TypeAlias ( key string , value string ) bson.D {
140+ return bson.D {bson.E {Key : key , Value : bson. D {{ Key : TypeOp , Value : value }} }}
141141}
142142
143- func Or ( conditions ... any ) bson.D {
144- return bson.D {bson.E {Key : OrOp , Value : conditions }}
143+ func TypeArray ( key string , values ... bsontype. Type ) bson.D {
144+ return bson.D {bson.E {Key : key , Value : bson. D {{ Key : TypeOp , Value : values }} }}
145145}
146146
147- func Slice (key string , number int ) bson.D {
148- return bson.D {bson.E {Key : key , Value : bson.D {{Key : SliceOp , Value : number }}}}
147+ func TypeArrayAlias (key string , values ... string ) bson.D {
148+ return bson.D {bson.E {Key : key , Value : bson.D {{Key : TypeOp , Value : values }}}}
149149}
150150
151- func SliceRanger ( key string , start , end int ) bson.D {
152- return bson.D {bson.E {Key : key , Value : bson. D {{ Key : SliceOp , Value : [] int { start , end }}} }}
151+ func Where ( value string ) bson.D {
152+ return bson.D {bson.E {Key : WhereOp , Value : value }}
153153}
0 commit comments