@dozerjs/dozer
TypeScript icon, indicating that this package has built-in type declarations

0.0.10 • Public • Published


Connect any data source, combine them in real-time and instantly get low-latency gRPC and REST APIs.
⚡ All with just a simple configuration! ⚡️


CI Coverage Status Docs Join on Discord License


Overview

This repository is a typescript wrapper over gRPC APIs that are automatically generated when you run Dozer.

Installation

yarn add @dozerjs/dozer

Instance

  const client = new DozerClient();
  const endpoint = client.getEndpoint('flights');

Methods

Count()

Count query returns number of records in particular source.

  const count = await endpoint.count();

Query(query = string | null)

Query method is used to fetch records from cache. Reference to gRPC method is here

  const [fields, records] = await endpoint.query();

Also, client supports query parameter, which allows to filter, sort and paginate. More about you can find here

import { Order } from "@dozerjs/dozer";

const query = {
    orderBy: {
        start: Order.ASC
    }
}

const [fields, records] = await endpoint.query(query);

OnEvent(eventType: EventType = EventType.ALL)

Other available option is to use events streams method onEvent. It connects to the gRPC stream and sends changes to the client. This method has eventType parameter, which is used to determine what type of changes will be streamed. Available options are ALL, INSERT_ONLY, UPDATE_ONLY, DELETE_ONLY.

import { EventType, DozerEndpointEvent, DozerFilter } from "@dozerjs/dozer";

const filter: DozerFilter | null = null;

endpoints.onEvent((evt: DozerEndpointEvent) => {
  console.log(evt.data);
  console.log(evt.fields);
  console.log(evt.primaryIndexKeys);
  console.log(evt.operation);
  console.log(evt.mapper);
}, EventType.INSERT_ONLY, filter);

/@dozerjs/dozer/

    Package Sidebar

    Install

    npm i @dozerjs/dozer

    Weekly Downloads

    1

    Version

    0.0.10

    License

    none

    Unpacked Size

    1.23 MB

    Total Files

    92

    Last publish

    Collaborators

    • chubei
    • karolisgud
    • dozer_admin