1 | import { FieldType } from "./grammar";
|
2 | export interface ISchemaOptions {
|
3 | |
4 |
|
5 |
|
6 | measurement: string;
|
7 | |
8 |
|
9 |
|
10 |
|
11 | database?: string;
|
12 | |
13 |
|
14 |
|
15 | fields: {
|
16 | [column: string]: FieldType;
|
17 | };
|
18 | |
19 |
|
20 |
|
21 | tags: string[];
|
22 | }
|
23 | export declare type FieldMap = {
|
24 | [name: string]: string | number | boolean;
|
25 | };
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | export 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 | */
|
58 | export declare function coerceBadly(fields: FieldMap): Array<[string, string]>;
|