-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc.go
29 lines (27 loc) · 1.13 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package mongoutils
import "go.mongodb.org/mongo-driver/bson/primitive"
// MongoDoc mongo document (primitive.D) builder
type MongoDoc interface {
// Add add new element
Add(k string, v any) MongoDoc
// Doc add new element with nested doc value
Doc(k string, cb func(d MongoDoc) MongoDoc) MongoDoc
// Array add new element with array value
Array(k string, v ...any) MongoDoc
// DocArray add new array element with doc
DocArray(k string, cb func(d MongoDoc) MongoDoc) MongoDoc
// Nested add new nested element
Nested(root string, k string, v any) MongoDoc
// NestedDoc add new nested element with doc value
NestedDoc(root string, k string, cb func(d MongoDoc) MongoDoc) MongoDoc
// NestedArray add new nested element with array value
NestedArray(root string, k string, v ...any) MongoDoc
// NestedDocArray add new nested array element with doc
NestedDocArray(root string, k string, cb func(d MongoDoc) MongoDoc) MongoDoc
// Regex add new element with regex value
Regex(k string, pattern string, opt string) MongoDoc
// Map creates a map from the elements of the Doc
Map() primitive.M
// Build generate mongo doc
Build() primitive.D
}