@@ -39,28 +39,20 @@ import "github.com/julien040/anyquery/rpc"
39
39
//
40
40
// It should return a new table instance, the database schema and if there is an error
41
41
func {{.TableName}}Creator(args rpc.TableCreatorArgs) (rpc.Table, *rpc.DatabaseSchema, error) {
42
- // Example: get a token from the user configuration
42
+ // Get a token from the user configuration
43
43
// token := args.UserConfig.GetString("token")
44
44
// if token == "" {
45
45
// return nil, nil, fmt.Errorf("token must be set in the plugin configuration")
46
46
// }
47
47
48
- // Example: open a cache connection
48
+ // Open a cache connection
49
49
/* cache, err := helper.NewCache(helper.NewCacheArgs{
50
50
Paths: []string{"{{.TableName}}", "{{.TableName}}" + "_cache"},
51
51
EncryptionKey: []byte("my_secret_key"),
52
52
})*/
53
53
54
54
return &{{.TableName}}Table{}, &rpc.DatabaseSchema{
55
- HandlesInsert: false,
56
- HandlesUpdate: false,
57
- HandlesDelete: false,
58
- HandleOffset: false,
59
55
Columns: []rpc.DatabaseSchemaColumn{
60
- {
61
- Name: "id",
62
- Type: rpc.ColumnTypeString,
63
- },
64
56
{
65
57
// This column is a parameter
66
58
// Therefore, it'll be hidden in SELECT * but will be used in WHERE clauses
@@ -70,6 +62,11 @@ func {{.TableName}}Creator(args rpc.TableCreatorArgs) (rpc.Table, *rpc.DatabaseS
70
62
IsParameter: true,
71
63
IsRequired: false,
72
64
},
65
+ {
66
+ Name: "id",
67
+ Type: rpc.ColumnTypeString,
68
+ },
69
+
73
70
},
74
71
}, nil
75
72
}
@@ -106,6 +103,8 @@ func (t *{{.TableName}}Cursor) Query(constraints rpc.QueryConstraint) ([][]inter
106
103
}
107
104
108
105
// A slice of rows to insert
106
+ // Uncomment the code to add support for inserting rows
107
+ /*
109
108
func (t *{{.TableName}}Table) Insert(rows [][]interface{}) error {
110
109
// Example: insert the rows in a database
111
110
// for _, row := range rows {
@@ -115,19 +114,25 @@ func (t *{{.TableName}}Table) Insert(rows [][]interface{}) error {
115
114
// }
116
115
return nil
117
116
}
117
+ */
118
118
119
119
// A slice of rows to update
120
120
// The first element of each row is the primary key
121
121
// while the rest are the values to update
122
122
// The primary key is therefore present twice
123
+ // Uncomment the code to add support for updating rows
124
+ /*
123
125
func (t *{{.TableName}}Table) Update(rows [][]interface{}) error {
124
126
return nil
125
- }
127
+ }*/
126
128
127
129
// A slice of primary keys to delete
130
+ // Uncomment the code to add support for deleting rows
131
+ /*
128
132
func (t *{{.TableName}}Table) Delete(primaryKeys []interface{}) error {
129
133
return nil
130
134
}
135
+ */
131
136
132
137
// A destructor to clean up resources
133
138
func (t *{{.TableName}}Table) Close() error {
@@ -144,6 +149,9 @@ all: $(files)
144
149
prod: $(files)
145
150
go build -o {{.ModuleName}}.out -ldflags "-s -w" $(files)
146
151
152
+ release: prod
153
+ goreleaser build -f .goreleaser.yaml --clean --snapshot
154
+
147
155
clean:
148
156
rm -f {{.ModuleName}}.out
149
157
@@ -352,6 +360,14 @@ func DevInit(cmd *cobra.Command, args []string) error {
352
360
return fmt .Errorf ("could not import rpc package: %w" , err )
353
361
}
354
362
363
+ goCmd = exec .Command ("go" , "get" , "-u" , "github.com/julien040/anyquery/rpc/helper" )
364
+ goCmd .Stdout = os .Stdout
365
+ goCmd .Stderr = os .Stderr
366
+ err = goCmd .Run ()
367
+ if err != nil {
368
+ return fmt .Errorf ("could not import rpc package: %w" , err )
369
+ }
370
+
355
371
// Create the main.go file
356
372
mainFile , err := os .Create ("main.go" )
357
373
if err != nil {
0 commit comments