9
9
"io"
10
10
"net/url"
11
11
"time"
12
-
13
- com "github.com/sqlitebrowser/dbhub.io/common"
14
12
)
15
13
16
14
const (
@@ -44,12 +42,12 @@ func (c *Connection) ChangeVerifyServerCert(b bool) {
44
42
}
45
43
46
44
// Branches returns a list of all available branches of a database along with the name of the default branch
47
- func (c Connection ) Branches (dbOwner , dbName string ) (branches map [string ]com. BranchEntry , defaultBranch string , err error ) {
45
+ func (c Connection ) Branches (dbOwner , dbName string ) (branches map [string ]BranchEntry , defaultBranch string , err error ) {
48
46
// Prepare the API parameters
49
47
data := c .PrepareVals (dbOwner , dbName , Identifier {})
50
48
51
49
// Fetch the list of branches and the default branch
52
- var response com. BranchListResponseContainer
50
+ var response BranchListResponseContainer
53
51
queryUrl := c .Server + "/v1/branches"
54
52
err = sendRequestJSON (queryUrl , c .VerifyServerCert , data , & response )
55
53
@@ -60,7 +58,7 @@ func (c Connection) Branches(dbOwner, dbName string) (branches map[string]com.Br
60
58
}
61
59
62
60
// Columns returns the column information for a given table or view
63
- func (c Connection ) Columns (dbOwner , dbName string , ident Identifier , table string ) (columns []com. APIJSONColumn , err error ) {
61
+ func (c Connection ) Columns (dbOwner , dbName string , ident Identifier , table string ) (columns []APIJSONColumn , err error ) {
64
62
// Prepare the API parameters
65
63
data := c .PrepareVals (dbOwner , dbName , ident )
66
64
data .Set ("table" , table )
@@ -72,7 +70,7 @@ func (c Connection) Columns(dbOwner, dbName string, ident Identifier, table stri
72
70
}
73
71
74
72
// Commits returns the details of all commits for a database
75
- func (c Connection ) Commits (dbOwner , dbName string ) (commits map [string ]com. CommitEntry , err error ) {
73
+ func (c Connection ) Commits (dbOwner , dbName string ) (commits map [string ]CommitEntry , err error ) {
76
74
// Prepare the API parameters
77
75
data := c .PrepareVals (dbOwner , dbName , Identifier {})
78
76
@@ -123,7 +121,7 @@ func (c Connection) Delete(dbName string) (err error) {
123
121
124
122
// Diff returns the differences between two commits of two databases, or if the details on the second database are left empty,
125
123
// between two commits of the same database. You can also specify the merge strategy used for the generated SQL statements.
126
- func (c Connection ) Diff (dbOwnerA , dbNameA string , identA Identifier , dbOwnerB , dbNameB string , identB Identifier , merge MergeStrategy ) (diffs com. Diffs , err error ) {
124
+ func (c Connection ) Diff (dbOwnerA , dbNameA string , identA Identifier , dbOwnerB , dbNameB string , identB Identifier , merge MergeStrategy ) (diffs Diffs , err error ) {
127
125
// Prepare the API parameters
128
126
data := url.Values {}
129
127
data .Set ("apikey" , c .APIKey )
@@ -190,7 +188,7 @@ func (c Connection) Execute(dbOwner, dbName string, sql string) (rowsChanged int
190
188
data .Set ("sql" , base64 .StdEncoding .EncodeToString ([]byte (sql )))
191
189
192
190
// Run the query on the remote database
193
- var execResponse com. ExecuteResponseContainer
191
+ var execResponse ExecuteResponseContainer
194
192
queryUrl := c .Server + "/v1/execute"
195
193
err = sendRequestJSON (queryUrl , c .VerifyServerCert , data , & execResponse )
196
194
if err != nil {
@@ -201,7 +199,7 @@ func (c Connection) Execute(dbOwner, dbName string, sql string) (rowsChanged int
201
199
}
202
200
203
201
// Indexes returns the list of indexes present in the database, along with the table they belong to
204
- func (c Connection ) Indexes (dbOwner , dbName string , ident Identifier ) (idx []com. APIJSONIndex , err error ) {
202
+ func (c Connection ) Indexes (dbOwner , dbName string , ident Identifier ) (idx []APIJSONIndex , err error ) {
205
203
// Prepare the API parameters
206
204
data := c .PrepareVals (dbOwner , dbName , ident )
207
205
@@ -212,7 +210,7 @@ func (c Connection) Indexes(dbOwner, dbName string, ident Identifier) (idx []com
212
210
}
213
211
214
212
// Metadata returns the metadata (branches, releases, tags, commits, etc) for the database
215
- func (c Connection ) Metadata (dbOwner , dbName string ) (meta com. MetadataResponseContainer , err error ) {
213
+ func (c Connection ) Metadata (dbOwner , dbName string ) (meta MetadataResponseContainer , err error ) {
216
214
// Prepare the API parameters
217
215
data := c .PrepareVals (dbOwner , dbName , Identifier {})
218
216
@@ -260,7 +258,7 @@ func (c Connection) Query(dbOwner, dbName string, ident Identifier, blobBase64 b
260
258
data .Set ("sql" , base64 .StdEncoding .EncodeToString ([]byte (sql )))
261
259
262
260
// Run the query on the remote database
263
- var returnedData []com. DataRow
261
+ var returnedData []DataRow
264
262
queryUrl := c .Server + "/v1/query"
265
263
err = sendRequestJSON (queryUrl , c .VerifyServerCert , data , & returnedData )
266
264
if err != nil {
@@ -274,10 +272,10 @@ func (c Connection) Query(dbOwner, dbName string, ident Identifier, blobBase64 b
274
272
var oneRow ResultRow
275
273
for _ , l := range j {
276
274
switch l .Type {
277
- case com . Float , com . Integer , com . Text :
275
+ case Float , Integer , Text :
278
276
// Float, integer, and text fields are added to the output
279
277
oneRow .Fields = append (oneRow .Fields , fmt .Sprint (l .Value ))
280
- case com . Binary :
278
+ case Binary :
281
279
// BLOB data is optionally Base64 encoded, or just skipped (using an empty string as placeholder)
282
280
if blobBase64 {
283
281
// Safety check. Make sure we've received a string
@@ -302,7 +300,7 @@ func (c Connection) Query(dbOwner, dbName string, ident Identifier, blobBase64 b
302
300
}
303
301
304
302
// Releases returns the details of all releases for a database
305
- func (c Connection ) Releases (dbOwner , dbName string ) (releases map [string ]com. ReleaseEntry , err error ) {
303
+ func (c Connection ) Releases (dbOwner , dbName string ) (releases map [string ]ReleaseEntry , err error ) {
306
304
// Prepare the API parameters
307
305
data := c .PrepareVals (dbOwner , dbName , Identifier {})
308
306
@@ -324,7 +322,7 @@ func (c Connection) Tables(dbOwner, dbName string, ident Identifier) (tbl []stri
324
322
}
325
323
326
324
// Tags returns the details of all tags for a database
327
- func (c Connection ) Tags (dbOwner , dbName string ) (tags map [string ]com. TagEntry , err error ) {
325
+ func (c Connection ) Tags (dbOwner , dbName string ) (tags map [string ]TagEntry , err error ) {
328
326
// Prepare the API parameters
329
327
data := c .PrepareVals (dbOwner , dbName , Identifier {})
330
328
@@ -440,7 +438,7 @@ func (c Connection) UploadLive(dbName string, dbBytes *[]byte) (err error) {
440
438
}
441
439
442
440
// Webpage returns the URL of the database file in the webUI. eg. for web browsers
443
- func (c Connection ) Webpage (dbOwner , dbName string ) (webPage com. WebpageResponseContainer , err error ) {
441
+ func (c Connection ) Webpage (dbOwner , dbName string ) (webPage WebpageResponseContainer , err error ) {
444
442
// Prepare the API parameters
445
443
data := c .PrepareVals (dbOwner , dbName , Identifier {})
446
444
0 commit comments