Back

[SOLVED] update document is working only once and not twice or more

  • 0
  • Databases
  • Web
  • Cloud
otik
5 Jun, 2023, 17:16

When you load the document, what does it look like? Can you send...

TL;DR
The user had an issue with a document not updating multiple times. They tried some suggestions but nothing worked. Eventually, it was discovered that the issue was caused by the permissions transforming from an array to an object, preventing multiple updates. The solution was to ensure that the permissions were sent as an empty array.
Susmita
5 Jun, 2023, 17:16

It's like this

otik
5 Jun, 2023, 17:19

I mean data from function "getDocument"

Susmita
5 Jun, 2023, 17:23

I'm using listDocument

otik
5 Jun, 2023, 17:23

So that

Susmita
5 Jun, 2023, 17:23

and the data which I'm getting is in the above image only

Susmita
5 Jun, 2023, 17:23

Here I'm trying to update a document

Binyamin
5 Jun, 2023, 18:26

I'm trying to understand the problem

So this function runs only once?

TypeScript
const editTips = (id) => {
    const promise = databases.updateDocument(databaseId,
      collectionId, id, data);
    promise.then(
      function(response) {
        toast.success('Productivity tip updated successfully!!');
        console.log(response);
        // window.location.reload()
      },
      function(error) {
        toast.error(error.message);
        console.log(error);
      }
    );
  };
otik
5 Jun, 2023, 18:31

I had a same issue, it was that when you updated document, permissions then transform from string[] into object, then you can't update document twice, but in this case, there should be an err

Binyamin
5 Jun, 2023, 18:33

Interesting, but why the permissions were deleted? have you send the permissions as an empty array?

Drake
5 Jun, 2023, 20:02

Did the original poster mention anything about malformed permissions? 🧐

Susmita
6 Jun, 2023, 04:13

At first it was running only once

Susmita
6 Jun, 2023, 04:13

So, I created this support issue

Susmita
6 Jun, 2023, 04:13

After that I closed my laptop for 3hrs

Susmita
6 Jun, 2023, 04:13

then when I tried to check

Susmita
6 Jun, 2023, 04:13

Nothing is working

Susmita
6 Jun, 2023, 04:13

Current problem: Document is not getting updated

Susmita
6 Jun, 2023, 04:14

The code is above

Susmita
6 Jun, 2023, 04:14

I have changed nothing

safwan
6 Jun, 2023, 07:00

@Susmita In my personal experience, the <form> tag is a pain to work with (again, just my preference). Could you try getting rid of the form tag, and replacing it with a simple div? Also get rid of the type="submit" in the button. For now, try to just click the button manually.

Another thing to check is the form's action property. It's blank, which if I'm not wrong will basically refresh your page.

safwan
6 Jun, 2023, 07:00

Try these things and let me know

Susmita
6 Jun, 2023, 12:13

Okay, let me try

Susmita
6 Jun, 2023, 12:43

Hey, thanks

Susmita
6 Jun, 2023, 12:43

It's working fine now

Susmita
6 Jun, 2023, 12:43

[SOLVED] update document is working only once and not twice or more

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