1
1
//
2
2
// DISCLAIMER
3
3
//
4
- // Copyright 2020 ArangoDB GmbH, Cologne, Germany
4
+ // Copyright 2020-2023 ArangoDB GmbH, Cologne, Germany
5
5
//
6
6
// Licensed under the Apache License, Version 2.0 (the "License");
7
7
// you may not use this file except in compliance with the License.
17
17
//
18
18
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19
19
//
20
- // Author Adam Janikowski
21
- //
22
20
23
21
package arangodb
24
22
@@ -79,7 +77,7 @@ func (c clientDatabase) AccessibleDatabases(ctx context.Context) ([]Database, er
79
77
}
80
78
81
79
func (c clientDatabase ) DatabaseExists (ctx context.Context , name string ) (bool , error ) {
82
- _ , err := c .Database (ctx , name )
80
+ _ , err := c .GetDatabase (ctx , name , nil )
83
81
if err == nil {
84
82
return true , nil
85
83
}
@@ -97,6 +95,16 @@ func (c clientDatabase) Databases(ctx context.Context) ([]Database, error) {
97
95
}
98
96
99
97
func (c clientDatabase ) Database (ctx context.Context , name string ) (Database , error ) {
98
+ return c .GetDatabase (ctx , name , nil )
99
+ }
100
+
101
+ func (c clientDatabase ) GetDatabase (ctx context.Context , name string , options * GetDatabaseOptions ) (Database , error ) {
102
+ db := newDatabase (c .client , name )
103
+
104
+ if options != nil && options .SkipExistCheck {
105
+ return db , nil
106
+ }
107
+
100
108
url := connection .NewUrl ("_db" , name , "_api" , "database" , "current" )
101
109
102
110
var response struct {
@@ -111,7 +119,7 @@ func (c clientDatabase) Database(ctx context.Context, name string) (Database, er
111
119
112
120
switch code := resp .Code (); code {
113
121
case http .StatusOK :
114
- return newDatabase ( c . client , name ) , nil
122
+ return db , nil
115
123
default :
116
124
return nil , response .AsArangoErrorWithCode (code )
117
125
}
0 commit comments