appwrite/docs/examples/1.6.x/server-go/examples/databases/create-relationship-attribute.md
2024-08-21 14:46:51 +05:30

927 B

package main

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

func main() { client := client.NewClient()

client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key

service := databases.NewDatabases(client)
response, error := service.CreateRelationshipAttribute(
    "<DATABASE_ID>",
    "<COLLECTION_ID>",
    "<RELATED_COLLECTION_ID>",
    "oneToOne",
    databases.WithCreateRelationshipAttributeTwoWay(false),
    databases.WithCreateRelationshipAttributeKey(""),
    databases.WithCreateRelationshipAttributeTwoWayKey(""),
    databases.WithCreateRelationshipAttributeOnDelete("cascade"),
)

if error != nil {
    panic(error)
}

fmt.Println(response)

}