Skip to content

Commit

Permalink
ADD appwrite log.
Browse files Browse the repository at this point in the history
  • Loading branch information
karminski committed Sep 30, 2023
1 parent f8217c4 commit 7f4c6ac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/actionruntime/appwrite/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package appwrite

import (
"fmt"
"strings"

"github.com/illacloud/appwrite-sdk-go/appwrite"
Expand All @@ -23,7 +24,10 @@ import (

func (a *Connector) getClientWithOpts(Opts map[string]interface{}) (*appwrite.Databases, error) {
// format resource options
fmt.Printf("[DUMP] getClientWithOpts.Opts: %+v\n", Opts)
if err := mapstructure.Decode(Opts, &a.Resource); err != nil {
fmt.Printf("[DUMP] getClientWithOpts.err: %+v\n", err)

return nil, err
}

Expand All @@ -35,6 +39,7 @@ func (a *Connector) getClientWithOpts(Opts map[string]interface{}) (*appwrite.Da

// create appwrite database service
database := appwrite.NewDatabases(client)
fmt.Printf("[DUMP] getClientWithOpts.database: %+v\n", database)

return database, nil
}
Expand Down
8 changes: 8 additions & 0 deletions src/actionruntime/appwrite/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package appwrite
import (
"encoding/json"
"errors"
"fmt"

"github.com/go-playground/validator/v10"
"github.com/illacloud/builder-backend/src/actionruntime/common"
Expand Down Expand Up @@ -80,13 +81,20 @@ func (a *Connector) TestConnection(resourceOpts map[string]interface{}) (common.
func (a *Connector) GetMetaInfo(resourceOpts map[string]interface{}) (common.MetaInfoResult, error) {
// get appwrite database client
db, err := a.getClientWithOpts(resourceOpts)
fmt.Printf("[DUMP] GetMetaInfo.db: %+v\n", db)
fmt.Printf("[DUMP] GetMetaInfo.err: %+v\n", err)

if err != nil {
return common.MetaInfoResult{Success: false}, err
}

// get collections
var EmptyArray = []interface{}{}
colls, err := db.ListCollections(a.Resource.DatabaseID, EmptyArray, "")
fmt.Printf("[DUMP] GetMetaInfo.colls: %+v\n", colls)
fmt.Printf("[DUMP] GetMetaInfo.colls.Result: %+v\n", colls.Result)
fmt.Printf("[DUMP] GetMetaInfo.err: %+v\n", err)

if err != nil {
return common.MetaInfoResult{Success: false}, err
}
Expand Down
2 changes: 1 addition & 1 deletion src/controller/resource_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (controller *Controller) GetResourceMetaInfo(c *gin.Context, resource *mode
// check template
resourceMetaInfo, errInGetMetaInfo := resourceAssemblyLine.GetMetaInfo(resource.ExportOptionsInMap())
if errInGetMetaInfo != nil {
controller.FeedbackBadRequest(c, ERROR_FLAG_VALIDATE_REQUEST_BODY_FAILED, "ger resource meta info error: "+errInGetMetaInfo.Error())
controller.FeedbackBadRequest(c, ERROR_FLAG_VALIDATE_REQUEST_BODY_FAILED, "get resource meta info error: "+errInGetMetaInfo.Error())
return nil, errInGetMetaInfo
}

Expand Down

0 comments on commit 7f4c6ac

Please sign in to comment.