#[SOLVED] Inconsistency between online Doc and Examples in libs?

16 messages · Page 1 of 1 (latest)

unkempt nova
#

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.

atomic grove
#

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?

unkempt nova
#

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?

slate shuttle
slate shuttle
unkempt nova
#

I did a npm i node-appwrite to embed it with my function and found that code in the node_module/node-appwrite then.

slate shuttle
unkempt nova
#

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...

slate shuttle
unkempt nova
#

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.