初始化
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
|||||||
|
package mongodbx
|
||||||
|
|
||||||
|
func NewMongodb(opts ...Option) {
|
||||||
|
options := defaultOptions()
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(options)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: connect to mongodb
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package mongodbx
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
package mongodbx
|
||||||
|
|
||||||
|
type mongodbOptions struct {
|
||||||
|
Host string
|
||||||
|
}
|
||||||
|
|
||||||
|
func defaultOptions() *mongodbOptions {
|
||||||
|
return &mongodbOptions{
|
||||||
|
Host: "localhost:27017",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
type Option func(*mongodbOptions)
|
||||||
|
|
||||||
|
func WithHost(host string) Option {
|
||||||
|
return func(o *mongodbOptions) {
|
||||||
|
o.Host = host
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user