fauna
Version:
A driver to query Fauna databases in browsers, Node.js, and other Javascript runtimes
40 lines (39 loc) • 1.22 kB
TypeScript
import { FeedSuccess, QueryValue, StreamEventData, QueryStats } from "../wire-protocol";
/**
* A token used to initiate a Fauna event source at a particular snapshot in time.
*
* The example below shows how to request an event token from Fauna and use it
* to establish an event steam.
*
* @example
* ```javascript
* const response = await client.query(fql`
* Messages.byRecipient(User.byId("1234"))
* `);
* const eventSource = response.data;
*
* const stream = client.stream(eventSource)
* .on("add", (event) => console.log("New message", event))
*
* stream.start();
* ```
*/
export interface EventSource {
readonly token: string;
}
export declare function isEventSource(value: any): value is EventSource;
export declare class StreamToken implements EventSource {
readonly token: string;
constructor(token: string);
}
/**
* A class to represent a page of events from a Fauna stream.
*/
export declare class FeedPage<T extends QueryValue> {
#private;
readonly events: IterableIterator<StreamEventData<T>>;
readonly cursor: string;
readonly hasNext: boolean;
readonly stats?: QueryStats;
constructor({ events, cursor, has_next, stats }: FeedSuccess<T>);
}