After Insert Hook

Hi everyone !:grinning:

I am having a query, which points →

  1. User A inserts a value to database.
  2. User A’s dataset should refresh.
  3. At the same time User B’s dataset should also refresh.
    Database fields → User A’s userId , User B’s userId , Value.

What I am trying to do can, exactly, be found here →

https://stackoverflow.com/questions/61196489/what-the-best-way-to-refresh-a-wix-repeater-when-a-new-message-receive

Is it possible to achieve the above.
Any help will be greatly appreciated !!!

Have a nice - day or evening or night !!!

Any idea ??

One and two are very easy.
You insert a value to the database using .insert() and in the .then() part you .refresh() the dataset.

Number 3 is a little bit more difficult and depends on how many users you have.

If you don’t have a too many users, you can query the database every second or two and if the collection has been changed, refresh the dataset.

If you have a lot of users and you’re afraid that it’ll be too many queries per second, you can install one of the web socket NPMs and use them to update the users in real time.

@jonatandor35 Thanks one more !!
Is there any role here for afterInsert . ???
Thanks !!!

@ajithkrr if you go for the web socket solution, then yes.