Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 6 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# # Change Log
# Change Log

## v0.14.0

* Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance
* Add `Operator` class for atomic modification of rows via update, bulk update, upsert, and bulk upsert operations

## v0.13.1

Expand Down Expand Up @@ -47,7 +52,3 @@
## 0.3.0

* Add new push message parameters


## v0.13.1

22 changes: 22 additions & 0 deletions account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,13 @@ func (srv *Account) UpdateEmail(Email string, Password string)(*models.User, err
}
type ListIdentitiesOptions struct {
Queries []string
Total bool
enabledSetters map[string]bool
}
func (options ListIdentitiesOptions) New() *ListIdentitiesOptions {
options.enabledSetters = map[string]bool{
"Queries": false,
"Total": false,
}
return &options
}
Expand All @@ -175,6 +177,12 @@ func (srv *Account) WithListIdentitiesQueries(v []string) ListIdentitiesOption {
o.enabledSetters["Queries"] = true
}
}
func (srv *Account) WithListIdentitiesTotal(v bool) ListIdentitiesOption {
return func(o *ListIdentitiesOptions) {
o.Total = v
o.enabledSetters["Total"] = true
}
}

// ListIdentities get the list of identities for the currently logged in user.
func (srv *Account) ListIdentities(optionalSetters ...ListIdentitiesOption)(*models.IdentityList, error) {
Expand All @@ -187,6 +195,9 @@ func (srv *Account) ListIdentities(optionalSetters ...ListIdentitiesOption)(*mod
if options.enabledSetters["Queries"] {
params["queries"] = options.Queries
}
if options.enabledSetters["Total"] {
params["total"] = options.Total
}
headers := map[string]interface{}{
}

Expand Down Expand Up @@ -287,11 +298,13 @@ func (srv *Account) CreateJWT()(*models.Jwt, error) {
}
type ListLogsOptions struct {
Queries []string
Total bool
enabledSetters map[string]bool
}
func (options ListLogsOptions) New() *ListLogsOptions {
options.enabledSetters = map[string]bool{
"Queries": false,
"Total": false,
}
return &options
}
Expand All @@ -302,6 +315,12 @@ func (srv *Account) WithListLogsQueries(v []string) ListLogsOption {
o.enabledSetters["Queries"] = true
}
}
func (srv *Account) WithListLogsTotal(v bool) ListLogsOption {
return func(o *ListLogsOptions) {
o.Total = v
o.enabledSetters["Total"] = true
}
}

// ListLogs get the list of latest security activity logs for the currently
// logged in user. Each log returns user IP address, location and date and
Expand All @@ -316,6 +335,9 @@ func (srv *Account) ListLogs(optionalSetters ...ListLogsOption)(*models.LogList,
if options.enabledSetters["Queries"] {
params["queries"] = options.Queries
}
if options.enabledSetters["Total"] {
params["total"] = options.Total
}
headers := map[string]interface{}{
}

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.13.1 (%s; %s)", runtime.GOOS, runtime.GOARCH),
"user-agent" : fmt.Sprintf("AppwriteGoSDK/v0.14.0 (%s; %s)", runtime.GOOS, runtime.GOARCH),
"x-sdk-name": "Go",
"x-sdk-platform": "server",
"x-sdk-language": "go",
"x-sdk-version": "v0.13.1",
"x-sdk-version": "v0.14.0",
}
httpClient, err := GetDefaultClient(defaultTimeout)
if err != nil {
Expand Down
55 changes: 55 additions & 0 deletions databases/databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ func New(clt client.Client) *Databases {
type ListOptions struct {
Queries []string
Search string
Total bool
enabledSetters map[string]bool
}
func (options ListOptions) New() *ListOptions {
options.enabledSetters = map[string]bool{
"Queries": false,
"Search": false,
"Total": false,
}
return &options
}
Expand All @@ -44,6 +46,12 @@ func (srv *Databases) WithListSearch(v string) ListOption {
o.enabledSetters["Search"] = true
}
}
func (srv *Databases) WithListTotal(v bool) ListOption {
return func(o *ListOptions) {
o.Total = v
o.enabledSetters["Total"] = true
}
}

// List get a list of all databases from the current Appwrite project. You can
// use the search parameter to filter your results.
Expand All @@ -62,6 +70,9 @@ func (srv *Databases) List(optionalSetters ...ListOption)(*models.DatabaseList,
if options.enabledSetters["Search"] {
params["search"] = options.Search
}
if options.enabledSetters["Total"] {
params["total"] = options.Total
}
headers := map[string]interface{}{
}

Expand Down Expand Up @@ -600,12 +611,14 @@ func (srv *Databases) Delete(DatabaseId string)(*interface{}, error) {
type ListCollectionsOptions struct {
Queries []string
Search string
Total bool
enabledSetters map[string]bool
}
func (options ListCollectionsOptions) New() *ListCollectionsOptions {
options.enabledSetters = map[string]bool{
"Queries": false,
"Search": false,
"Total": false,
}
return &options
}
Expand All @@ -622,6 +635,12 @@ func (srv *Databases) WithListCollectionsSearch(v string) ListCollectionsOption
o.enabledSetters["Search"] = true
}
}
func (srv *Databases) WithListCollectionsTotal(v bool) ListCollectionsOption {
return func(o *ListCollectionsOptions) {
o.Total = v
o.enabledSetters["Total"] = true
}
}

// ListCollections get a list of all collections that belong to the provided
// databaseId. You can use the search parameter to filter your results.
Expand All @@ -642,6 +661,9 @@ func (srv *Databases) ListCollections(DatabaseId string, optionalSetters ...List
if options.enabledSetters["Search"] {
params["search"] = options.Search
}
if options.enabledSetters["Total"] {
params["total"] = options.Total
}
headers := map[string]interface{}{
}

Expand Down Expand Up @@ -920,11 +942,13 @@ func (srv *Databases) DeleteCollection(DatabaseId string, CollectionId string)(*
}
type ListAttributesOptions struct {
Queries []string
Total bool
enabledSetters map[string]bool
}
func (options ListAttributesOptions) New() *ListAttributesOptions {
options.enabledSetters = map[string]bool{
"Queries": false,
"Total": false,
}
return &options
}
Expand All @@ -935,6 +959,12 @@ func (srv *Databases) WithListAttributesQueries(v []string) ListAttributesOption
o.enabledSetters["Queries"] = true
}
}
func (srv *Databases) WithListAttributesTotal(v bool) ListAttributesOption {
return func(o *ListAttributesOptions) {
o.Total = v
o.enabledSetters["Total"] = true
}
}

// ListAttributes list attributes in the collection.
//
Expand All @@ -952,6 +982,9 @@ func (srv *Databases) ListAttributes(DatabaseId string, CollectionId string, opt
if options.enabledSetters["Queries"] {
params["queries"] = options.Queries
}
if options.enabledSetters["Total"] {
params["total"] = options.Total
}
headers := map[string]interface{}{
}

Expand Down Expand Up @@ -3038,12 +3071,14 @@ func (srv *Databases) UpdateRelationshipAttribute(DatabaseId string, CollectionI
type ListDocumentsOptions struct {
Queries []string
TransactionId string
Total bool
enabledSetters map[string]bool
}
func (options ListDocumentsOptions) New() *ListDocumentsOptions {
options.enabledSetters = map[string]bool{
"Queries": false,
"TransactionId": false,
"Total": false,
}
return &options
}
Expand All @@ -3060,6 +3095,12 @@ func (srv *Databases) WithListDocumentsTransactionId(v string) ListDocumentsOpti
o.enabledSetters["TransactionId"] = true
}
}
func (srv *Databases) WithListDocumentsTotal(v bool) ListDocumentsOption {
return func(o *ListDocumentsOptions) {
o.Total = v
o.enabledSetters["Total"] = true
}
}

// ListDocuments get a list of all the user's documents in a given collection.
// You can use the query params to filter your results.
Expand All @@ -3081,6 +3122,9 @@ func (srv *Databases) ListDocuments(DatabaseId string, CollectionId string, opti
if options.enabledSetters["TransactionId"] {
params["transactionId"] = options.TransactionId
}
if options.enabledSetters["Total"] {
params["total"] = options.Total
}
headers := map[string]interface{}{
}

Expand Down Expand Up @@ -3954,11 +3998,13 @@ func (srv *Databases) IncrementDocumentAttribute(DatabaseId string, CollectionId
}
type ListIndexesOptions struct {
Queries []string
Total bool
enabledSetters map[string]bool
}
func (options ListIndexesOptions) New() *ListIndexesOptions {
options.enabledSetters = map[string]bool{
"Queries": false,
"Total": false,
}
return &options
}
Expand All @@ -3969,6 +4015,12 @@ func (srv *Databases) WithListIndexesQueries(v []string) ListIndexesOption {
o.enabledSetters["Queries"] = true
}
}
func (srv *Databases) WithListIndexesTotal(v bool) ListIndexesOption {
return func(o *ListIndexesOptions) {
o.Total = v
o.enabledSetters["Total"] = true
}
}

// ListIndexes list indexes in the collection.
//
Expand All @@ -3986,6 +4038,9 @@ func (srv *Databases) ListIndexes(DatabaseId string, CollectionId string, option
if options.enabledSetters["Queries"] {
params["queries"] = options.Queries
}
if options.enabledSetters["Total"] {
params["total"] = options.Total
}
headers := map[string]interface{}{
}

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/list-identities.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ service := account.New(client)

response, error := service.ListIdentities(
account.WithListIdentitiesQueries([]interface{}{}),
account.WithListIdentitiesTotal(false),
)
1 change: 1 addition & 0 deletions docs/examples/account/list-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ service := account.New(client)

response, error := service.ListLogs(
account.WithListLogsQueries([]interface{}{}),
account.WithListLogsTotal(false),
)
1 change: 1 addition & 0 deletions docs/examples/databases/list-attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ response, error := service.ListAttributes(
"<DATABASE_ID>",
"<COLLECTION_ID>",
databases.WithListAttributesQueries([]interface{}{}),
databases.WithListAttributesTotal(false),
)
1 change: 1 addition & 0 deletions docs/examples/databases/list-collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ response, error := service.ListCollections(
"<DATABASE_ID>",
databases.WithListCollectionsQueries([]interface{}{}),
databases.WithListCollectionsSearch("<SEARCH>"),
databases.WithListCollectionsTotal(false),
)
1 change: 1 addition & 0 deletions docs/examples/databases/list-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ response, error := service.ListDocuments(
"<COLLECTION_ID>",
databases.WithListDocumentsQueries([]interface{}{}),
databases.WithListDocumentsTransactionId("<TRANSACTION_ID>"),
databases.WithListDocumentsTotal(false),
)
1 change: 1 addition & 0 deletions docs/examples/databases/list-indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ response, error := service.ListIndexes(
"<DATABASE_ID>",
"<COLLECTION_ID>",
databases.WithListIndexesQueries([]interface{}{}),
databases.WithListIndexesTotal(false),
)
1 change: 1 addition & 0 deletions docs/examples/databases/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ service := databases.New(client)
response, error := service.List(
databases.WithListQueries([]interface{}{}),
databases.WithListSearch("<SEARCH>"),
databases.WithListTotal(false),
)
1 change: 1 addition & 0 deletions docs/examples/functions/list-deployments.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ response, error := service.ListDeployments(
"<FUNCTION_ID>",
functions.WithListDeploymentsQueries([]interface{}{}),
functions.WithListDeploymentsSearch("<SEARCH>"),
functions.WithListDeploymentsTotal(false),
)
1 change: 1 addition & 0 deletions docs/examples/functions/list-executions.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ service := functions.New(client)
response, error := service.ListExecutions(
"<FUNCTION_ID>",
functions.WithListExecutionsQueries([]interface{}{}),
functions.WithListExecutionsTotal(false),
)
1 change: 1 addition & 0 deletions docs/examples/functions/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ service := functions.New(client)
response, error := service.List(
functions.WithListQueries([]interface{}{}),
functions.WithListSearch("<SEARCH>"),
functions.WithListTotal(false),
)
26 changes: 26 additions & 0 deletions docs/examples/messaging/create-resend-provider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/messaging"
)

client := client.New(
client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1")
client.WithProject("<YOUR_PROJECT_ID>")
client.WithKey("<YOUR_API_KEY>")
)

service := messaging.New(client)

response, error := service.CreateResendProvider(
"<PROVIDER_ID>",
"<NAME>",
messaging.WithCreateResendProviderApiKey("<API_KEY>"),
messaging.WithCreateResendProviderFromName("<FROM_NAME>"),
messaging.WithCreateResendProviderFromEmail("[email protected]"),
messaging.WithCreateResendProviderReplyToName("<REPLY_TO_NAME>"),
messaging.WithCreateResendProviderReplyToEmail("[email protected]"),
messaging.WithCreateResendProviderEnabled(false),
)
1 change: 1 addition & 0 deletions docs/examples/messaging/list-message-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ service := messaging.New(client)
response, error := service.ListMessageLogs(
"<MESSAGE_ID>",
messaging.WithListMessageLogsQueries([]interface{}{}),
messaging.WithListMessageLogsTotal(false),
)
1 change: 1 addition & 0 deletions docs/examples/messaging/list-messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ service := messaging.New(client)
response, error := service.ListMessages(
messaging.WithListMessagesQueries([]interface{}{}),
messaging.WithListMessagesSearch("<SEARCH>"),
messaging.WithListMessagesTotal(false),
)
Loading