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.
Summary
The user found a solution to their problem of inconsistency between the online documentation and the examples in the libraries. They resolved their issue with the network part on macOS Docker by using the `host.docker.internal` public IP. They also found a bug in the deployment process. The user discovered that their `package.json` was incorrect and may have been an old code example. They also mentioned using a different command to build the function package. They encountered an issue with an old version of a package, `node-appwrite`, and found that their `package-lock` showed a newer version. The user clarified where they were seeing an example without the database
joeyouss
Jun 10, 2023, 14:25
Hi lemme quiickly take a look
joeyouss
Jun 10, 2023, 14:29
also which page did you read this?
joeyouss
Jun 10, 2023, 14:41
also, to learn about why is it not working for you - any errors you got?
Gildas Quiniou
Rank 2: Process
Jun 10, 2023, 16:19
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?
Gildas Quiniou
Rank 2: Process
Jun 10, 2023, 16:31
Could I use http://appwrite-executor/v1 as endpoint?
Hmm... npmjs.org shows V 9.0.0. Why did I got such old version?
Gildas Quiniou
Rank 2: Process
Jun 10, 2023, 16:46
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?
Gildas Quiniou
Rank 2: Process
Jun 10, 2023, 16:51
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...
Drake
Admin
Jun 10, 2023, 17:12
Easiest thing to do is to use your LAN IP if you're running locally
Gildas Quiniou
Rank 2: Process
Jun 10, 2023, 17:21
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.
Drake
Admin
Jun 10, 2023, 21:18
[SOLVED] Inconsistency between online Doc and Examples in libs?