2025-06-19 12:43:27 +00:00
|
|
|
import { Client, Databases, RelationshipType, RelationMutate } from "https://deno.land/x/appwrite/mod.ts";
|
|
|
|
|
|
|
|
|
|
const 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
|
|
|
|
|
|
|
|
|
|
const databases = new Databases(client);
|
|
|
|
|
|
2025-08-20 07:22:48 +00:00
|
|
|
const response = await databases.createRelationshipAttribute({
|
|
|
|
|
databaseId: '<DATABASE_ID>',
|
|
|
|
|
collectionId: '<COLLECTION_ID>',
|
|
|
|
|
relatedCollectionId: '<RELATED_COLLECTION_ID>',
|
|
|
|
|
type: RelationshipType.OneToOne,
|
2025-08-26 03:40:03 +00:00
|
|
|
twoWay: false, // optional
|
|
|
|
|
key: '', // optional
|
|
|
|
|
twoWayKey: '', // optional
|
|
|
|
|
onDelete: RelationMutate.Cascade // optional
|
2025-08-20 07:22:48 +00:00
|
|
|
});
|