
Hi there,
I am new to Appwrite, and am trying to make a database storing a number associated with the userId. Here is my code.
Function call(Javascript) const payload = JSON.stringify({context: context, function:'get', userId: userId, amount: amount }); const result = await functions.createExecution("6770291b00171ec2611b", payload);
Function Code(Python): from appwrite.client import Client from appwrite.services.users import Users from appwrite.services.databases import Databases from appwrite.exception import AppwriteException import os key = os.API_KEY
This Appwrite function will be executed every time your function is triggered
def main(context,function, userId, amount): # You can use the Appwrite SDK to interact with other services # For this example, we're using the Users service client = ( Client() .set_endpoint('https://cloud.appwrite.io/v1') .set_project('67609b010021900fc6e6') .set_key(key) ) users = Users(client) databases = Databases(client) if(function == "get"): result = databases.get_document('6760b9c20030df251f1c','badgerBucks', userId) return res.result['badgerBucks'] elif(function == "set"): databases.update_document('6760b9c20030df251f1c','badgerBucks', userId, {'username': userId, 'badgerBucks': amount}) elif(function == "create"): database.creat_document('6760b9c20030df251f1c','badgerBucks',userId,{'username':userId,'badgerBucks':amount})
I am wondering if I should use the context parameter instead of the function parameter. I could not find much on the docs about how and what to use the context parameter for.
Thanks in advance,
-sharmnten

EDIT: the markdown formatting of discord messed up the some of the comments. Apologies.

Functions need to have a specific default entrypoint that accepts just the context
object or the de-structured objects within if the runtime supports it.
The context
in all runtimes contain 4 vars.
Request, Response, Log & Error.
See - https://appwrite.io/docs/products/functions/develop#context-object
Recommended threads
- mcp-for-docs not working properly
I'm experiencing issues integrating the MCP server tool with Cursor IDE. The MCP server connection establishes successfully initially but fails after one minute...
- When connecting to VCS (Version Control ...
Hello, when I try to define in my function the root path of a function I get this when I click "Update".
- queries.map is not a function
Query.createdBefore doesnt work ``` tables.updateRows({ databaseId: process.env.APPWRITE_DATABASE_ID, tableId: process.env.APPWRITE_TABLE_ID, ...
