appwrite/docs/examples/1.8.x/server-kotlin/java/tablesdb/create-relationship-column.md

35 lines
989 B
Markdown
Raw Normal View History

```java
2025-08-20 07:22:48 +00:00
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
2025-08-23 10:52:20 +00:00
import io.appwrite.services.TablesDB;
2025-08-20 07:22:48 +00:00
import io.appwrite.enums.RelationshipType;
2025-11-18 05:37:50 +00:00
import io.appwrite.enums.RelationMutate;
2025-08-20 07:22:48 +00:00
Client client = new Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>"); // Your secret API key
2025-08-23 10:52:20 +00:00
TablesDB tablesDB = new TablesDB(client);
2025-08-20 07:22:48 +00:00
2025-08-20 14:20:05 +00:00
tablesDB.createRelationshipColumn(
2025-08-20 07:22:48 +00:00
"<DATABASE_ID>", // databaseId
"<TABLE_ID>", // tableId
"<RELATED_TABLE_ID>", // relatedTableId
RelationshipType.ONETOONE, // type
false, // twoWay (optional)
"", // key (optional)
"", // twoWayKey (optional)
RelationMutate.CASCADE, // onDelete (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
return;
}
System.out.println(result);
})
);
```