When my appwrite function executes (hosted on appwrite console), the bulk operations don't execute (without error) unless I add a dev key as an API Key in the env vars on appwrite.
const client = new Client() .setEndpoint(process.env.API_ENDPOINT) .setProject(process.env.PROJECT_ID) .setKey(process.env.APPWRITE_FUNCTION_API_KEY || process.env.API_KEY)
when locally testing with docker, i have this API_key env var but I was thinking in functions I shouldnt need it so wanted to check im not doing anything wrong.
I am using node-appwrite 17.2.0
e.g. of this - my main.js will call this function and I will see the first console.log stating it will create n events but I never see an error console log or a success log. It then returns to the main.js and completes the script.
export async function handleCreateBlock(db, block) { const newEvents = createEventsFromBlock(block);
try {
console.log(`Creating ${newEvents.length} events using bulk operation...`);
const result = await db.createDocuments(
process.env.DATABASE_ID,
process.env.EVENTS_COLLECTION_ID,
newEvents
);
console.log(`Bulk creation successful: ${result.documents.length} events created`);
return result;
} catch (error) {
console.error("Error creating events:", error);
throw error;
}
}
so to be clear, if i add the API_KEY env var it works. I have also given all database scopes in the function settings
Have you given it the appropriate scopes?
https://appwrite.io/docs/products/functions/develop#dynamic-api-key
Recommended threads
- Bulk API limitations in self-hosted serv...
Environment: Appwrite Selfhost SDK: node-appwrite 28.0 Calling `upsertRows` (also applies to `createRows`/`updateRows`/`deleteRows`) with more than 100 rows fa...
- Android SDK: Kotlin null Value Not Updat...
Hi team, I think you should check the Android SDK implementation once, as it seems to have an issue handling Kotlin **null** values. For example: When I send:...
- Can't connect GitHub — 500 error at the ...
Appwrite Cloud, Pro plan, SFO region. All my Git connections vanished today — Sites and all 15 Functions now show no repository connected. When I try to add a ...