Skip to content
Back

correct syntax for client.subscribe - realtime

  • 0
  • Databases
  • Web
  • Realtime
  • Cloud
xpediter
24 Oct, 2024, 07:31

What is the correct syntax to trigger a realtime event only on my 3 collections for every document? With or without the brackets?

client.subscribe( ['databases.[63446ca755a041305f7f].collections.[66f7fce6002b828c5b50].documents', 'databases.[63446ca755a041305f7f].collections.[667be4de65e1cbaedb43].documents', 'databases.[63446ca755a041305f7f].collections.[667698d85d98f40d9f97].documents', 'files'], response => { // Callback will be executed on changes for documents and all files. console.log("realtime :", response); this.realtimePayload = response.payload; });

TL;DR
Correct syntax for client.subscribe in real-time should not include brackets `[]`. Use the following format for the subscribe method: ``` databases.databaseID.collections.collectionID.documents ``` Where `databaseID` and `collectionID` are the actual IDs. The correct channel formats can be found at https://appwrite.io/docs/apis/realtime#channels. To trigger a real-time event on specific collections for every document, include the following code without brackets: ``` client.subscribe( 'databases.63446ca755a041305f7f.collections.66f7fce6002b828c5b50.documents
darShan
24 Oct, 2024, 07:33
darShan
24 Oct, 2024, 07:33

and here's the correct channel formats - https://appwrite.io/docs/apis/realtime#channels

darShan
24 Oct, 2024, 07:34

also you dont need brackets []. should be just -

TypeScript
databases.databaseID.collections.collectionID.documents

where databaseID & collectionID are the actual IDs.

xpediter
24 Oct, 2024, 07:44

thank you very much 🙏

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