-
Notifications
You must be signed in to change notification settings - Fork 3
/
options.go
65 lines (56 loc) · 1.23 KB
/
options.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package bom
import (
"context"
"go.mongodb.org/mongo-driver/mongo"
"time"
)
// Option bom option type
type Option func(*Bom) error
// SetMongoClient set go.mongodb.org/mongo-driver client
func SetMongoClient(client *mongo.Client) Option {
return func(b *Bom) error {
b.client = client
return nil
}
}
// SetDatabaseName set db name
func SetDatabaseName(dbName string) Option {
return func(b *Bom) error {
b.dbName = dbName
return nil
}
}
// SetSkipWhenUpdating set skip fields when update
func SetSkipWhenUpdating(fieldsMap map[string]bool) Option {
return func(b *Bom) error {
b.skipWhenUpdating = fieldsMap
return nil
}
}
// SetCollection set collection name
func SetCollection(collection string) Option {
return func(b *Bom) error {
b.dbCollection = collection
return nil
}
}
// SetQueryTimeout set query timeout
func SetQueryTimeout(time time.Duration) Option {
return func(b *Bom) error {
b.queryTimeout = time
return nil
}
}
// SetModel set work model
func SetModel(document interface{}) Option {
return func(b *Bom) error {
b.model = document
return nil
}
}
// Deprecated: SetContext method should not be used
func SetContext(ctx context.Context) Option {
return func(b *Bom) error {
return nil
}
}