Back

verification and update document

  • 0
  • Databases
  • Users
zdanl
4 Dec, 2023, 23:24

two questions. the Server SDK for NodeJS says that if I want to do a 'verification' i think that means to set a users 'verified' status, the first parameter is a URL?! see sample.

secondly, to update a document i have to know the document id? can't i just query for it? i suppose i can, if the next parameter is an array of Query objects, but it should be documented. UPDATE: nope. i can't.

this should work, but

TypeScript
 80   databases.getDocument('cryptfire', 'api', [
 81     Query.equal('key', apikey)
 82   ]);

it may make more sense in this case

TypeScript
 80   databases.updateDocument('cryptfire', 'api', [
 81     Query.equal('key', apikey)
 82   ]);

because then you can do this, although it probably isn't best practice

TypeScript
    try {
      databases.getDocument('cryptfire', 'api', [
        Query.equal('key', apikey)
      ]);
      // do here what you gotta do
    } catch (err) {
      res.send('wrong apikey');
    }

thx & sry

TL;DR
The user is seeking guidance on creating a wrapper around database methods and mentions a helpful npm package. They also have questions about the Server SDK for NodeJS, specifically regarding the 'verification' process and updating documents. The user shares some code snippets and suggests a solution. Solution: The user is advised to use the npm package for inspiration. For the 'verification' process, the first parameter is indeed a URL. To update a document, the document ID needs to be known, and querying for it is not possible. The suggested solution is to use the `updateDocument` method with a Query object as a parameter. However, it is
Drake
5 Dec, 2023, 07:41

Please don't put multiple topics in a single post. The point of having support posts is to be able to focus on a single problem.

Drake
5 Dec, 2023, 07:43

You can think of get document as get document by id, list documents as find or query for documents, and update document as update document by id. These are the methods available to you so you can use them accordingly. If you want to create some sort of wrapper method does a list documents and then update document, you are free to do so

zdanl
5 Dec, 2023, 09:14

i understand. i finally got to the OpenAPIv3 spec, so with some focus, i should be able to go my ways with it now. I'm looking to increase the quality and lower the frequency of my questions.

WhiteWalker72
5 Dec, 2023, 09:29

If you're looking for some inspiration for a wrapper around the database methods you could take a look at: https://www.npmjs.com/package/appwrite-database-repository?activeTab=code It doesn't have a updateDocumentBy method yet but that would be a great addition πŸ™‚

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more