UNPKG

1.7 kBTypeScriptView Raw
1import { FieldType } from "./grammar";
2export interface ISchemaOptions {
3 /**
4 * The measurement name this schema is describing.
5 */
6 measurement: string;
7 /**
8 * The database the measurement lives under. Uses the default database
9 * if one is provided.
10 */
11 database?: string;
12 /**
13 * Columns is the map of column type definitions on the database.
14 */
15 fields: {
16 [column: string]: FieldType;
17 };
18 /**
19 * A list of schema tag names.
20 */
21 tags: string[];
22}
23export declare type FieldMap = {
24 [name: string]: string | number | boolean;
25};
26/**
27 * The Schema provides information and utilities for an InfluxDB measurement.
28 * @private
29 */
30export declare class Schema {
31 private readonly options;
32 private readonly _fieldNames;
33 private _tagHash;
34 constructor(options: ISchemaOptions);
35 /**
36 * CoerceFields converts a map of field values to a strings which
37 * can be injected into the line protocol without further escaping.
38 * The output is given in [key, value] pairs.
39 */
40 coerceFields(fields: FieldMap): Array<[string, string]>;
41 /**
42 * Throws an error if the tags include values other than
43 * what was specified in the schema. It returns a list of tag names.
44 */
45 checkTags(tags: {
46 [tag: string]: string;
47 }): string[];
48 /**
49 * Returns the 'db'.'measurement'[.'field'] referencing the current schema.
50 */
51 private _ref;
52}
53/**
54 * Coerces the field map to a set of writable values, a la coerceFields,
55 * using native guesses based on the field datatypes.
56 * @private
57 */
58export declare function coerceBadly(fields: FieldMap): Array<[string, string]>;