publish

Sends a real-time message to Kuzzle. The message will be dispatched to all clients with subscriptions matching the index, the collection and the message content.

The index and collection are indicative and serve only to distinguish the rooms. They are not required to exist in the database

Note: real-time messages are not persisted in the database.


publish (index, collection, message, [options])

Arguments Type Description
index
string
Index name
collection
string
Collection name
message
object
Message to send
options
object
Query options

options

Additional query options

Option Type
(default)
Description
queuable
boolean

(true)
Make this request queuable or not

Resolves

A boolean indicating if the message was successfully published.

Usage

const message = { realtime: 'rule the web' };

try {
  await kuzzle.realtime.publish(
    'i-dont-exist',
    'in-database',
    message
  );

  console.log('Success');
} catch (error) {
  console.error(error.message);
}