Moderator
@huylv What's the SDK you're using?
Votes
1
Replies
24
Participants
Unknown
Messages
25
Moderator
@huylv What's the SDK you're using?
Rank 1: Thread
I used "node-appwrite": "^9.0.0" to write cloud functions
Moderator
Then you should list executions this way:
const promise = functions.listExecutions('[FUNCTION_ID]');
promise.then(function (response) { console.log(response);}, function (error) { console.log(error);});Rank 1: Thread
my implementation:
const executions = await Appwrite.functions.listExecutions(createOrderFunctionId, [
Query.equal("status", "waiting"),
Query.equal("status", "processing"),
])
they are the same @D5
Rank 1: Thread
what wrong with my query?
Moderator
Check if there is any log in the container: appwrite-worker-functions
Rank 1: Thread
I found this log about this function
Moderator
what about docker compose logs appwrite?
Rank 1: Thread
error no configuration file provided: not found
Moderator
can you show the complete log?
Rank 1: Thread
there is no log, docker compose logs appwrite show that error
Rank 1: Thread
Rank 1: Thread
If there is no solution, it's hard to use appwrite on production 😦
Moderator
Did you have set in your appwrite instance an API key?
Moderator
I will also need to do a similar implementation
Admin
You essentially need to create a lock. You can do this by creating a locks collection. When a user executes the create order function, it'll create a document in the locks collection with ID of the user. If the document is created successfully, it'll continue to process the order. Before the function finishes, it must delete the document to release the lock.
Moderator
Seems like the other functions will get executed before the document has been created.
Admin
What do you mean?
Moderator
The user is checking if an element already exists in database, I think that should not be different from creating a lock collection. The problem is that the first function creates the element so other run simultaneously will not "see" the firstly created document.
Admin
I wasn't suggesting to check for a document. The first execution will create the document. If another execution tries to run at the same time, the create document will fail so the function will exit
Moderator
@huylv Then try this
Moderator
I will try too next week
Rank 1: Thread
I tried and it worked as expected. Thanks Steven and D5, but is this a formal way to achieve this. I though Database transaction is the solution for almost project
Admin
feel free to 👍🏼 this issue for transactions: https://github.com/appwrite/appwrite/issues/2788
Rank 1: Thread
[SOLVED] Prevent cheater from spam execute function