Comparing version 5.1.1 to 5.2.0
@@ -248,2 +248,9 @@ /// <reference types="node" /> | ||
/** | ||
* Adds specified schema for better fields coercing. | ||
* | ||
* @param {ISchemaOptions} schema | ||
* @memberof InfluxDB | ||
*/ | ||
addSchema(schema: ISchemaOptions): void; | ||
/** | ||
* Creates a new database with the provided name. | ||
@@ -677,2 +684,10 @@ * @param databaseName | ||
private _getQueryOpts; | ||
/** | ||
* Creates specified measurement schema | ||
* | ||
* @private | ||
* @param {ISchemaOptions} schema | ||
* @memberof InfluxDB | ||
*/ | ||
private _createSchema; | ||
} |
@@ -239,16 +239,14 @@ "use strict"; | ||
}); | ||
this._options.schema.forEach(schema => { | ||
schema.database = schema.database || this._options.database; | ||
const db = schema.database; | ||
if (!db) { | ||
throw new Error(`Schema ${schema.measurement} doesn't have a database specified,` + | ||
'and no default database is provided!'); | ||
} | ||
if (!this._schema[db]) { | ||
this._schema[db] = Object.create(null); | ||
} | ||
this._schema[db][schema.measurement] = new schema_1.Schema(schema); | ||
}); | ||
this._options.schema.forEach(schema => this._createSchema(schema)); | ||
} | ||
/** | ||
* Adds specified schema for better fields coercing. | ||
* | ||
* @param {ISchemaOptions} schema | ||
* @memberof InfluxDB | ||
*/ | ||
addSchema(schema) { | ||
this._createSchema(schema); | ||
} | ||
/** | ||
* Creates a new database with the provided name. | ||
@@ -918,3 +916,21 @@ * @param databaseName | ||
} | ||
/** | ||
* Creates specified measurement schema | ||
* | ||
* @private | ||
* @param {ISchemaOptions} schema | ||
* @memberof InfluxDB | ||
*/ | ||
_createSchema(schema) { | ||
schema.database = schema.database || this._options.database; | ||
if (!schema.database) { | ||
throw new Error(`Schema ${schema.measurement} doesn't have a database specified,` + | ||
'and no default database is provided!'); | ||
} | ||
if (!this._schema[schema.database]) { | ||
this._schema[schema.database] = Object.create(null); | ||
} | ||
this._schema[schema.database][schema.measurement] = new schema_1.Schema(schema); | ||
} | ||
} | ||
exports.InfluxDB = InfluxDB; |
{ | ||
"name": "influx", | ||
"version": "5.1.1", | ||
"version": "5.2.0", | ||
"description": "InfluxDB Client", | ||
@@ -79,5 +79,5 @@ "main": "./lib/src/index.js", | ||
"stream-http": "github:node-influx/stream-http", | ||
"ts-node": "8.2.0", | ||
"ts-node": "8.3.0", | ||
"typescript": "3.5.2", | ||
"webpack": "4.34.0" | ||
"webpack": "4.35.0" | ||
}, | ||
@@ -84,0 +84,0 @@ "eslintConfig": { |
140080
3910