Hi, I'm fighting with writing functions and I discovered some inconsistency in the docs.
The doc say const promise = databases.createDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]', {});
but looking at the node-appwrite
lib I found async createDocument(collectionId, documentId, data, read, write)
. It's missing the [DATABASE_ID]
part? Is the online doc up-to-date? BTW, none of the 2 work for me at the moment, but am I missing something? Anywhere with some sample with functions creating docs? Thx.
Hi lemme quiickly take a look
also which page did you read this?
also, to learn about why is it not working for you - any errors you got?
Well, the doc is here : https://appwrite.io/docs/server/databases?sdk=nodejs-default#databasesCreateDocument
The code is node-appwrite/lib/services/database.js
~line #800. Also the examples in node-appwrite/docs/examples/database/create-document.md
(line 14).
Regarding my code I just found that my endpoint is not suitable for localhost
environment but strangely I didn't have any error until now... Gonna investigate. BTW, the doc suggest using the host IP but I'm not confident with that, as by default a container should not be able to connect to host. Also, I'm on macOS, that could be a reason for the host IP to be unreachable. Should I use some other IP from a network build up by Docker?
Could I use http://appwrite-executor/v1
as endpoint?
Can you clarify where you're seeing the example without the database id? Im looking at https://github.com/appwrite/sdk-for-node/blob/68e46fd078183c05d36c31caa2a3979076ae4f83/docs/examples/databases/create-document.md?plain=1#L14 and I see database id.
A container can connect to the host if the host is listening on the port
No, that's not the right service
I did a npm i node-appwrite
to embed it with my function and found that code in the node_module/node-appwrite
then.
What's the package.json in there say for the version? Or maybe you can look in your package lock
Sure. From package-lock
:
"packages": {
"": {
...
"dependencies": {
...
"node-appwrite": "^5.0.0"
}
},
then
...
"node_modules/node-appwrite": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/node-appwrite/-/node-appwrite-5.1.0.tgz",
"integrity": "sha512-CuSa4z7mh0VgR+VkjKWVuwpwiDU2pHNkSFpSEEo/gYJXgPpaNWguJfdJJKFTbUgC1CfIRUHYBLQIdHTX/LgsIg==",
"dependencies": {
"axios": "^0.26.1",
"form-data": "^4.0.0"
}
},
Hmm... npmjs.org
shows V 9.0.0. Why did I got such old version?
BTW, I also use docker run --rm --interactive --tty --volume $PWD:/usr/code openruntimes/node:v2-18.0 sh /usr/local/src/build.sh
to build the function package. It should be more up-to-date, no?
OK, got it, my package.json
was wrong. I may have picked an old code example. The package is in sync with the doc. Remain my prob with the endpoint...
Easiest thing to do is to use your LAN IP if you're running locally
Unfortunately on macOS Docker is running in a VM. They did a good just to make it work as close as it does on a native Linux machine but the network part is a piece of tweaks. Hopefully I just got it to work, the public IP can be replaced by host.docker.internal
which bridges to the localhost IP stack and all seem to work as expected now! Thanks for your help.
BTW, I found a bug in the way the Deployment works, even if I leave the Activate deployment after build
unchecked (Manual option), the deployment is done anyway.
[SOLVED] Inconsistency between online Doc and Examples in libs?
Recommended threads
- Get team fail in appwrite function
I try to get team of a user inside appwrite function, but i get this error: `AppwriteException: User (role: guests) missing scope (teams.read)` If i try on cl...
- Deploy function not working - 503
Hellon i get this error message, when i try to deploy a new version of a function <html><body><h1>503 Service Unavailable</h1>No server is available to handle...
- Error When load the website
Hi, I am getting this error whenever I reload my website please help me, I am using react Error: ** GET https://cloud.appwrite.io/v1/account 401 (Unauthoriz...