axiodb 15.1.0 → 16.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/VERSION +1 -0
- package/cli/cmd/collection.go +169 -0
- package/cli/cmd/connect.go +597 -0
- package/cli/cmd/db.go +171 -0
- package/cli/cmd/document.go +376 -0
- package/cli/cmd/index.go +101 -0
- package/cli/cmd/ping.go +36 -0
- package/cli/cmd/root.go +36 -0
- package/cli/cmd/version.go +41 -0
- package/cli/go.mod +15 -0
- package/cli/go.sum +20 -0
- package/cli/internal/config/config.go +111 -0
- package/cli/main.go +7 -0
- package/cli/pkg/commands/collection.go +68 -0
- package/cli/pkg/commands/db.go +62 -0
- package/cli/pkg/commands/document.go +184 -0
- package/cli/pkg/commands/index.go +51 -0
- package/cli/pkg/protocol/auth.go +46 -0
- package/cli/pkg/protocol/client.go +174 -0
- package/cli/pkg/protocol/message.go +75 -0
- package/opencode.json +9 -0
- package/package.json +1 -1
package/cli/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
16.2.0
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
package cmd
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
|
|
6
|
+
"github.com/nexoral/axiodb-cli/internal/config"
|
|
7
|
+
"github.com/nexoral/axiodb-cli/pkg/commands"
|
|
8
|
+
"github.com/nexoral/axiodb-cli/pkg/protocol"
|
|
9
|
+
"github.com/spf13/cobra"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
var collectionCmd = &cobra.Command{
|
|
13
|
+
Use: "collection",
|
|
14
|
+
Short: "Collection operations",
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
var collectionCreateCmd = &cobra.Command{
|
|
18
|
+
Use: "create <name>",
|
|
19
|
+
Short: "Create a collection",
|
|
20
|
+
Args: cobra.ExactArgs(1),
|
|
21
|
+
RunE: func(cmd *cobra.Command, args []string) error {
|
|
22
|
+
cfg, err := config.FromFlags(cmd)
|
|
23
|
+
if err != nil {
|
|
24
|
+
return err
|
|
25
|
+
}
|
|
26
|
+
if cfg.DB == "" {
|
|
27
|
+
return fmt.Errorf("--db flag is required")
|
|
28
|
+
}
|
|
29
|
+
client, err := cfg.ConnectAndAuth()
|
|
30
|
+
if err != nil {
|
|
31
|
+
return err
|
|
32
|
+
}
|
|
33
|
+
defer client.Disconnect()
|
|
34
|
+
|
|
35
|
+
resp, err := commands.CreateCollection(client, cfg.DB, args[0])
|
|
36
|
+
if err != nil {
|
|
37
|
+
return err
|
|
38
|
+
}
|
|
39
|
+
return printOutput(cfg.Output, resp)
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var collectionDeleteCmd = &cobra.Command{
|
|
44
|
+
Use: "delete <name>",
|
|
45
|
+
Short: "Delete a collection",
|
|
46
|
+
Args: cobra.ExactArgs(1),
|
|
47
|
+
RunE: func(cmd *cobra.Command, args []string) error {
|
|
48
|
+
cfg, err := config.FromFlags(cmd)
|
|
49
|
+
if err != nil {
|
|
50
|
+
return err
|
|
51
|
+
}
|
|
52
|
+
if cfg.DB == "" {
|
|
53
|
+
return fmt.Errorf("--db flag is required")
|
|
54
|
+
}
|
|
55
|
+
client, err := cfg.ConnectAndAuth()
|
|
56
|
+
if err != nil {
|
|
57
|
+
return err
|
|
58
|
+
}
|
|
59
|
+
defer client.Disconnect()
|
|
60
|
+
|
|
61
|
+
resp, err := commands.DeleteCollection(client, cfg.DB, args[0])
|
|
62
|
+
if err != nil {
|
|
63
|
+
return err
|
|
64
|
+
}
|
|
65
|
+
return printOutput(cfg.Output, resp)
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var collectionExistsCmd = &cobra.Command{
|
|
70
|
+
Use: "exists <name>",
|
|
71
|
+
Short: "Check if a collection exists",
|
|
72
|
+
Args: cobra.ExactArgs(1),
|
|
73
|
+
RunE: func(cmd *cobra.Command, args []string) error {
|
|
74
|
+
cfg, err := config.FromFlags(cmd)
|
|
75
|
+
if err != nil {
|
|
76
|
+
return err
|
|
77
|
+
}
|
|
78
|
+
if cfg.DB == "" {
|
|
79
|
+
return fmt.Errorf("--db flag is required")
|
|
80
|
+
}
|
|
81
|
+
client, err := cfg.ConnectAndAuth()
|
|
82
|
+
if err != nil {
|
|
83
|
+
return err
|
|
84
|
+
}
|
|
85
|
+
defer client.Disconnect()
|
|
86
|
+
|
|
87
|
+
exists, err := commands.CollectionExists(client, cfg.DB, args[0])
|
|
88
|
+
if err != nil {
|
|
89
|
+
return err
|
|
90
|
+
}
|
|
91
|
+
fmt.Printf("Collection '%s' exists: %v\n", args[0], exists)
|
|
92
|
+
return nil
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var collectionInfoCmd = &cobra.Command{
|
|
97
|
+
Use: "info",
|
|
98
|
+
Short: "Get collection information",
|
|
99
|
+
RunE: func(cmd *cobra.Command, args []string) error {
|
|
100
|
+
cfg, err := config.FromFlags(cmd)
|
|
101
|
+
if err != nil {
|
|
102
|
+
return err
|
|
103
|
+
}
|
|
104
|
+
if cfg.DB == "" {
|
|
105
|
+
return fmt.Errorf("--db flag is required")
|
|
106
|
+
}
|
|
107
|
+
client, err := cfg.ConnectAndAuth()
|
|
108
|
+
if err != nil {
|
|
109
|
+
return err
|
|
110
|
+
}
|
|
111
|
+
defer client.Disconnect()
|
|
112
|
+
|
|
113
|
+
resp, err := commands.GetCollectionInfo(client, cfg.DB)
|
|
114
|
+
if err != nil {
|
|
115
|
+
return err
|
|
116
|
+
}
|
|
117
|
+
return printOutput(cfg.Output, resp)
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
var collectionListCmd = &cobra.Command{
|
|
122
|
+
Use: "list",
|
|
123
|
+
Short: "List all collections in a database",
|
|
124
|
+
RunE: func(cmd *cobra.Command, args []string) error {
|
|
125
|
+
cfg, err := config.FromFlags(cmd)
|
|
126
|
+
if err != nil {
|
|
127
|
+
return err
|
|
128
|
+
}
|
|
129
|
+
if cfg.DB == "" {
|
|
130
|
+
return fmt.Errorf("--db flag is required")
|
|
131
|
+
}
|
|
132
|
+
client, err := cfg.ConnectAndAuth()
|
|
133
|
+
if err != nil {
|
|
134
|
+
return err
|
|
135
|
+
}
|
|
136
|
+
defer client.Disconnect()
|
|
137
|
+
|
|
138
|
+
resp, err := commands.GetCollectionInfo(client, cfg.DB)
|
|
139
|
+
if err != nil {
|
|
140
|
+
return err
|
|
141
|
+
}
|
|
142
|
+
return printOutput(cfg.Output, resp)
|
|
143
|
+
},
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
func init() {
|
|
147
|
+
collectionCmd.AddCommand(collectionCreateCmd)
|
|
148
|
+
collectionCmd.AddCommand(collectionDeleteCmd)
|
|
149
|
+
collectionCmd.AddCommand(collectionExistsCmd)
|
|
150
|
+
collectionCmd.AddCommand(collectionInfoCmd)
|
|
151
|
+
collectionCmd.AddCommand(collectionListCmd)
|
|
152
|
+
rootCmd.AddCommand(collectionCmd)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
func createCollection(client *protocol.Client, dbName, collName string) (*protocol.Response, error) {
|
|
156
|
+
return commands.CreateCollection(client, dbName, collName)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
func deleteCollection(client *protocol.Client, dbName, collName string) (*protocol.Response, error) {
|
|
160
|
+
return commands.DeleteCollection(client, dbName, collName)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
func collectionExists(client *protocol.Client, dbName, collName string) (bool, error) {
|
|
164
|
+
return commands.CollectionExists(client, dbName, collName)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
func getCollectionInfo(client *protocol.Client, dbName string) (*protocol.Response, error) {
|
|
168
|
+
return commands.GetCollectionInfo(client, dbName)
|
|
169
|
+
}
|