🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

@graffy/index-watcher

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graffy/index-watcher

Watch provider for the index pattern:

latest
Source
npmnpm
Version
0.14.8-beta.1
Version published
Maintainers
1
Created
Source

Graffy Index Watcher

Watch provider for the index pattern:

{
  users: { userId: { ... }, ... },
  users$: {
    encodedParameters: page({
      [indexKey]: link('/users/userId'),
      ...
    }),
    ...
  }
}

Here, users$ is an index into the users collection.

While it is straightforward to create a watch provider (change stream) for the users tree, it is not as easy to create one for the users$ tree, especially when arbitrary filtering parameters are supported. IndexWatcher can help craft an index change stream using the entity change stream and an indexing function:

store.use(
  '/users$',
  IndexWatcher(
    '/users', // Entity path prefix
    { country: true, createTime: true }, // Entity sub-query
    (user, params) => {
      // Indexing function
      if (params.country !== user.country) return; // Exclude from index.
      return [user.createTime]; // An array of index keys.
    },
  ),
);

This assumes:

  • Index and entity trees with the same structure as above

See Graffy documentation for more.

FAQs

Package last updated on 05 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts