Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## v0.16.0

* Added ability to create columns and indexes synchronously while creating a table

## v0.15.0

* Rename `VCSDeploymentType` enum to `VCSReferenceType`
Expand Down
4 changes: 2 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ type Client struct {
func New(optionalSetters ...ClientOption) Client {
headers := map[string]string{
"X-Appwrite-Response-Format" : "1.8.0",
"user-agent" : fmt.Sprintf("AppwriteGoSDK/v0.15.0 (%s; %s)", runtime.GOOS, runtime.GOARCH),
"user-agent" : fmt.Sprintf("AppwriteGoSDK/v0.16.0 (%s; %s)", runtime.GOOS, runtime.GOARCH),
"x-sdk-name": "Go",
"x-sdk-platform": "server",
"x-sdk-language": "go",
"x-sdk-version": "v0.15.0",
"x-sdk-version": "v0.16.0",
}
httpClient, err := GetDefaultClient(defaultTimeout)
if err != nil {
Expand Down
22 changes: 22 additions & 0 deletions databases/databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,13 +695,17 @@ type CreateCollectionOptions struct {
Permissions []string
DocumentSecurity bool
Enabled bool
Attributes []interface{}
Indexes []interface{}
enabledSetters map[string]bool
}
func (options CreateCollectionOptions) New() *CreateCollectionOptions {
options.enabledSetters = map[string]bool{
"Permissions": false,
"DocumentSecurity": false,
"Enabled": false,
"Attributes": false,
"Indexes": false,
}
return &options
}
Expand All @@ -724,6 +728,18 @@ func (srv *Databases) WithCreateCollectionEnabled(v bool) CreateCollectionOption
o.enabledSetters["Enabled"] = true
}
}
func (srv *Databases) WithCreateCollectionAttributes(v []interface{}) CreateCollectionOption {
return func(o *CreateCollectionOptions) {
o.Attributes = v
o.enabledSetters["Attributes"] = true
}
}
func (srv *Databases) WithCreateCollectionIndexes(v []interface{}) CreateCollectionOption {
return func(o *CreateCollectionOptions) {
o.Indexes = v
o.enabledSetters["Indexes"] = true
}
}

// CreateCollection create a new Collection. Before using this route, you
// should create a new database resource using either a [server
Expand Down Expand Up @@ -751,6 +767,12 @@ func (srv *Databases) CreateCollection(DatabaseId string, CollectionId string, N
if options.enabledSetters["Enabled"] {
params["enabled"] = options.Enabled
}
if options.enabledSetters["Attributes"] {
params["attributes"] = options.Attributes
}
if options.enabledSetters["Indexes"] {
params["indexes"] = options.Indexes
}
headers := map[string]interface{}{
"content-type": "application/json",
}
Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-anonymous-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
client := client.New(
client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1")
client.WithProject("<YOUR_PROJECT_ID>")
client.WithSession("")
)

service := account.New(client)
Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-email-password-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
client := client.New(
client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1")
client.WithProject("<YOUR_PROJECT_ID>")
client.WithSession("")
)

service := account.New(client)
Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-email-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
client := client.New(
client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1")
client.WithProject("<YOUR_PROJECT_ID>")
client.WithSession("")
)

service := account.New(client)
Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-jwt.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
client := client.New(
client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1")
client.WithProject("<YOUR_PROJECT_ID>")
client.WithSession("")
)

service := account.New(client)
Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-magic-url-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
client := client.New(
client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1")
client.WithProject("<YOUR_PROJECT_ID>")
client.WithSession("")
)

service := account.New(client)
Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-mfa-challenge.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
client := client.New(
client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1")
client.WithProject("<YOUR_PROJECT_ID>")
client.WithSession("")
)

service := account.New(client)
Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-o-auth-2-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
client := client.New(
client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1")
client.WithProject("<YOUR_PROJECT_ID>")
client.WithSession("")
)

service := account.New(client)
Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-phone-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
client := client.New(
client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1")
client.WithProject("<YOUR_PROJECT_ID>")
client.WithSession("")
)

service := account.New(client)
Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
client := client.New(
client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1")
client.WithProject("<YOUR_PROJECT_ID>")
client.WithSession("")
)

service := account.New(client)
Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
client := client.New(
client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1")
client.WithProject("<YOUR_PROJECT_ID>")
client.WithSession("")
)

service := account.New(client)
Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/update-magic-url-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
client := client.New(
client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1")
client.WithProject("<YOUR_PROJECT_ID>")
client.WithSession("")
)

service := account.New(client)
Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/update-phone-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
client := client.New(
client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1")
client.WithProject("<YOUR_PROJECT_ID>")
client.WithSession("")
)

service := account.New(client)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/avatars/get-screenshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ response, error := service.GetScreenshot(
avatars.WithGetScreenshotUserAgent("Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15"),
avatars.WithGetScreenshotFullpage(true),
avatars.WithGetScreenshotLocale("en-US"),
avatars.WithGetScreenshotTimezone("America/New_York"),
avatars.WithGetScreenshotTimezone("america/new_york"),
avatars.WithGetScreenshotLatitude(37.7749),
avatars.WithGetScreenshotLongitude(-122.4194),
avatars.WithGetScreenshotAccuracy(100),
Expand Down
2 changes: 2 additions & 0 deletions docs/examples/databases/create-collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ response, error := service.CreateCollection(
databases.WithCreateCollectionPermissions(interface{}{"read("any")"}),
databases.WithCreateCollectionDocumentSecurity(false),
databases.WithCreateCollectionEnabled(false),
databases.WithCreateCollectionAttributes([]interface{}{}),
databases.WithCreateCollectionIndexes([]interface{}{}),
)
2 changes: 2 additions & 0 deletions docs/examples/tablesdb/create-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ response, error := service.CreateTable(
tablesdb.WithCreateTablePermissions(interface{}{"read("any")"}),
tablesdb.WithCreateTableRowSecurity(false),
tablesdb.WithCreateTableEnabled(false),
tablesdb.WithCreateTableColumns([]interface{}{}),
tablesdb.WithCreateTableIndexes([]interface{}{}),
)
22 changes: 22 additions & 0 deletions tablesdb/tables_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,13 +683,17 @@ type CreateTableOptions struct {
Permissions []string
RowSecurity bool
Enabled bool
Columns []interface{}
Indexes []interface{}
enabledSetters map[string]bool
}
func (options CreateTableOptions) New() *CreateTableOptions {
options.enabledSetters = map[string]bool{
"Permissions": false,
"RowSecurity": false,
"Enabled": false,
"Columns": false,
"Indexes": false,
}
return &options
}
Expand All @@ -712,6 +716,18 @@ func (srv *TablesDB) WithCreateTableEnabled(v bool) CreateTableOption {
o.enabledSetters["Enabled"] = true
}
}
func (srv *TablesDB) WithCreateTableColumns(v []interface{}) CreateTableOption {
return func(o *CreateTableOptions) {
o.Columns = v
o.enabledSetters["Columns"] = true
}
}
func (srv *TablesDB) WithCreateTableIndexes(v []interface{}) CreateTableOption {
return func(o *CreateTableOptions) {
o.Indexes = v
o.enabledSetters["Indexes"] = true
}
}

// CreateTable create a new Table. Before using this route, you should create
// a new database resource using either a [server
Expand All @@ -737,6 +753,12 @@ func (srv *TablesDB) CreateTable(DatabaseId string, TableId string, Name string,
if options.enabledSetters["Enabled"] {
params["enabled"] = options.Enabled
}
if options.enabledSetters["Columns"] {
params["columns"] = options.Columns
}
if options.enabledSetters["Indexes"] {
params["indexes"] = options.Indexes
}
headers := map[string]interface{}{
"content-type": "application/json",
}
Expand Down