Rank 4: Virtual Machine
in https://appwrite.io/docs/products/databases/relationships#create-documents we create a spiderman movie, with unique ID. ```js
const { Client, Databases, ID } = require('node-appwrite');
const client = new Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<PROJECT_ID>'); // Your project ID
const databases = new Databases(client);
await databases.createDocument(
'marvel',
'movies',
ID.unique(),
{
title: 'Spiderman',
year: 2002,
reviews: [
{ author: 'Bob', text: 'Great movie!' },
{ author: 'Alice', text: 'Loved it!' }
]
}
)
but in the next update section, we update by passing title? not ID?js
const { Client, Databases } = require('node-appwrite');
const client = new Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<PROJECT_ID>'); // Your project ID
const databases = new Databases(client);
await databases.updateDocument(
'marvel',
'movies',
'spiderman',
{
title: 'Spiderman',
year: 2002,
reviews: [
'review4',
'review5'
]
}
);