MCPcopy Create free account
hub / github.com/upper/db / open

Method open

adapter/mongo/database.go:166–189  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

164}
165
166func (s *Source) open() error {
167 var err error
168
169 ctx, cancel := context.WithTimeout(context.Background(), connTimeout)
170 defer cancel()
171
172 opts := []*options.ClientOptions{
173 options.Client().ApplyURI(s.connURL.String()),
174 }
175
176 if s.session, err = mongo.Connect(ctx, opts...); err != nil {
177 return fmt.Errorf("mongo.Connect: %w", err)
178 }
179
180 s.collections = map[string]*Collection{}
181 s.database = s.session.Database(settings.Database)
182
183 // ping
184 if err = s.Ping(); err != nil {
185 return fmt.Errorf("Ping: %w", err)
186 }
187
188 return nil
189}
190
191// Close terminates the current database session.
192func (s *Source) Close() error {

Callers 2

OpenMethod · 0.95
CloneMethod · 0.95

Calls 3

PingMethod · 0.95
StringMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected