-
Notifications
You must be signed in to change notification settings - Fork 44
feat: Node.js SDK update for version 19.1.0-rc.1 #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const sdk = require('node-appwrite'); | ||
|
||
const client = new sdk.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 sdk.Databases(client); | ||
|
||
const result = await databases.createOperations({ | ||
transactionId: '<TRANSACTION_ID>', | ||
operations: [ | ||
{ | ||
"action": "create", | ||
"databaseId": "<DATABASE_ID>", | ||
"collectionId": "<COLLECTION_ID>", | ||
"documentId": "<DOCUMENT_ID>", | ||
"data": { | ||
"name": "Walter O'Brien" | ||
} | ||
} | ||
] // optional | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const sdk = require('node-appwrite'); | ||
|
||
const client = new sdk.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 sdk.Databases(client); | ||
|
||
const result = await databases.createTransaction({ | ||
ttl: 60 // optional | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const sdk = require('node-appwrite'); | ||
|
||
const client = new sdk.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 sdk.Databases(client); | ||
|
||
const result = await databases.deleteTransaction({ | ||
transactionId: '<TRANSACTION_ID>' | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const sdk = require('node-appwrite'); | ||
|
||
const client = new sdk.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 sdk.Databases(client); | ||
|
||
const result = await databases.getTransaction({ | ||
transactionId: '<TRANSACTION_ID>' | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const sdk = require('node-appwrite'); | ||
|
||
const client = new sdk.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 sdk.Databases(client); | ||
|
||
const result = await databases.listTransactions({ | ||
queries: [] // optional | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -12,5 +12,6 @@ const result = await databases.updateDocument({ | |||||||||
collectionId: '<COLLECTION_ID>', | ||||||||||
documentId: '<DOCUMENT_ID>', | ||||||||||
data: {}, // optional | ||||||||||
permissions: ["read("any")"] // optional | ||||||||||
permissions: ["read("any")"], // optional | ||||||||||
transactionId: '<TRANSACTION_ID>' // optional | ||||||||||
Comment on lines
+15
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix invalid permissions syntax (broken quotes) and prefer Permission/Role helpers. Use SDK helpers to avoid syntax errors and mirror recommended usage. - permissions: ["read("any")"], // optional
+ permissions: [sdk.Permission.read(sdk.Role.any())], // optional
transactionId: '<TRANSACTION_ID>' // optional 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const sdk = require('node-appwrite'); | ||
|
||
const client = new sdk.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 sdk.Databases(client); | ||
|
||
const result = await databases.updateTransaction({ | ||
transactionId: '<TRANSACTION_ID>', | ||
commit: false, // optional | ||
rollback: false // optional | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -12,5 +12,6 @@ const result = await databases.upsertDocument({ | |||||||||
collectionId: '<COLLECTION_ID>', | ||||||||||
documentId: '<DOCUMENT_ID>', | ||||||||||
data: {}, | ||||||||||
permissions: ["read("any")"] // optional | ||||||||||
permissions: ["read("any")"], // optional | ||||||||||
transactionId: '<TRANSACTION_ID>' // optional | ||||||||||
Comment on lines
+15
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix invalid permissions example.
- permissions: ["read("any")"], // optional
+ permissions: [sdk.Permission.read(sdk.Role.any())], // optional Alternatively, if showing raw strings, use single quotes inside: 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const sdk = require('node-appwrite'); | ||
|
||
const client = new sdk.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 tablesDB = new sdk.TablesDB(client); | ||
|
||
const result = await tablesDB.createOperations({ | ||
transactionId: '<TRANSACTION_ID>', | ||
operations: [ | ||
{ | ||
"action": "create", | ||
"databaseId": "<DATABASE_ID>", | ||
"tableId": "<TABLE_ID>", | ||
"rowId": "<ROW_ID>", | ||
"data": { | ||
"name": "Walter O'Brien" | ||
} | ||
} | ||
] // optional | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -18,5 +18,6 @@ const result = await tablesDB.createRow({ | |||||||||
"age": 30, | ||||||||||
"isAdmin": false | ||||||||||
}, | ||||||||||
permissions: ["read("any")"] // optional | ||||||||||
permissions: ["read("any")"], // optional | ||||||||||
transactionId: '<TRANSACTION_ID>' // optional | ||||||||||
Comment on lines
+21
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix invalid permissions string quoting; use Permission/Role helpers. The current string literal is syntactically invalid in JS. Prefer the SDK helpers for clarity and type-safety. Apply: - permissions: ["read("any")"], // optional
+ permissions: [sdk.Permission.read(sdk.Role.any())], // optional 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const sdk = require('node-appwrite'); | ||
|
||
const client = new sdk.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 tablesDB = new sdk.TablesDB(client); | ||
|
||
const result = await tablesDB.createTransaction({ | ||
ttl: 60 // optional | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -13,5 +13,6 @@ const result = await tablesDB.decrementRowColumn({ | |||||||||||||||||||
rowId: '<ROW_ID>', | ||||||||||||||||||||
column: '', | ||||||||||||||||||||
value: null, // optional | ||||||||||||||||||||
min: null // optional | ||||||||||||||||||||
min: null, // optional | ||||||||||||||||||||
transactionId: '<TRANSACTION_ID>' // optional | ||||||||||||||||||||
}); | ||||||||||||||||||||
Comment on lines
15
to
18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don’t use null for numeric fields; omit or use a number. value/min are number | undefined. null will be sent and likely rejected. - value: null, // optional
- min: null, // optional
+ // value: 1, // optional
+ // min: 0, // optional Optionally include them with real numbers as shown, or leave them out entirely. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const sdk = require('node-appwrite'); | ||
|
||
const client = new sdk.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 tablesDB = new sdk.TablesDB(client); | ||
|
||
const result = await tablesDB.deleteTransaction({ | ||
transactionId: '<TRANSACTION_ID>' | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const sdk = require('node-appwrite'); | ||
|
||
const client = new sdk.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 tablesDB = new sdk.TablesDB(client); | ||
|
||
const result = await tablesDB.getTransaction({ | ||
transactionId: '<TRANSACTION_ID>' | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix invalid permissions syntax (broken quotes) and prefer Permission/Role helpers.
The string
["read("any")"]
is invalid JS. Use SDK helpers for clarity.Apply:
📝 Committable suggestion
🤖 Prompt for AI Agents