Connect any data source, combine them in real-time and instantly get low-latency gRPC and REST APIs.
⚡ All with just a simple configuration! ⚡️
This repository is a typescript wrapper over gRPC APIs that are automatically generated when you run Dozer.
yarn add @dozerjs/dozer
const client = new DozerClient();
const endpoint = client.getEndpoint('flights');
Count query returns number of records in particular source.
const count = await endpoint.count();
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);
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);