# Live Query

Live Query allows you to subscribe to a **Parse.Query** you are interested in. Once subscribed, the server will notify clients whenever a **Parse.Object** that matches the **Parse.Query** is created or updated, in real-time.

Suppose you're building a To Do app and multiple users can make edits to the list. **Parse.Query** would require you to constantly poll the server for status. That's not an ideal situation.&#x20;

A Live Query solves this and makes it to where the client can subscribe to a **Parse.Query** and when updates are made, the subscriber will be notified.&#x20;

## Setup

Live Query requires you to configure which collections can be subscribed to. There are two ways to configure collections, [**env.json**](#env-json) and [**live-query-classnames**](#live-query-classnames-hook) hook.&#x20;

### env.json

Open the **/src/env.json** file and update the **LIVE\_QUERY\_SETTINGS.classNames** array with the collection name you wish to include.&#x20;

{% code title="/src/env.json" %}

```css
{
    ...
    "LIVE_QUERY_SERVER": true,
    "LIVE_QUERY_SETTINGS": {
        "classNames": ["Changelog", "YourCollection"]
    },
    ...
}
```

{% endcode %}

{% hint style="info" %}
If you have multiple **env.json** files be sure to update them accordingly&#x20;
{% endhint %}

### live-query-classnames hook

{% code title="/src/app/MyPlugin/plugin.js" %}

```javascript
Actinium.Hook.register('live-query-classnames', classNames => {
    classNames.push('MyPluginCollection'); 
});
```

{% endcode %}

{% hint style="warning" %}
Using the **live-query-classnames** hook will execute regardless of your plugin's active status due to the fact that this hook is run before the server starts.&#x20;
{% endhint %}
