-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.go
47 lines (38 loc) · 985 Bytes
/
database.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
package harper
type Database struct {
Record
Schema string `json:"schema"`
}
type GetBackupOptions struct {
Table string `json:"table,omitempty"`
Tables []string `json:"tables,omitempty"`
}
func (c *Client) CreateDatabase(database string) error {
return c.opRequest(operation{
Operation: OP_CREATE_DATABASE,
Database: database,
}, nil)
}
func (c *Client) DropDatabase(database string) error {
return c.opRequest(operation{
Operation: OP_DROP_DATABASE,
Database: database,
}, nil)
}
func (c *Client) GetBackup(database string, options GetBackupOptions) ([]byte, error) {
var bytes = []byte{}
op := operation{
Operation: OP_GET_BACKUP,
Database: database,
}
err := c.opRequest(op, &bytes)
return bytes, err
}
func (c *Client) DescribeDatabase(database string) (*MessageResponse, error) {
var response MessageResponse
err := c.opRequest(operation{
Operation: OP_DESCRIBE_DATABASE,
Database: database,
}, &response)
return &response, err
}