collimator
Advanced tools
Comparing version
@@ -5,3 +5,3 @@ | ||
## collimator(db) | ||
## collimator.inspect(db) | ||
@@ -24,3 +24,3 @@ Inspect all enumerable table in a database, and return a promise that will | ||
* **Promise.\<Database>** *db* - The pg-promise connection | ||
* **Database** *db* - A pg-promise `Database` instance | ||
@@ -54,3 +54,3 @@ ### Return: | ||
* **Promise.\<Database>** *db* - The pg-promise connection | ||
* **Database** *db* - A pg-promise `Database` instance | ||
* **String** *name* - The name of the table to get the relationship definitions for | ||
@@ -75,3 +75,3 @@ | ||
* **Promise.\<Database>** *db* - The pg-promise connection | ||
* **Database** *db* - A pg-promise `Database` instance | ||
* **String** *name* - The name of the table to get the schema of | ||
@@ -151,3 +151,3 @@ | ||
* **Promise.\<Database>** *db* - The pg-promise connection | ||
* **Database** *db* - A pg-promise `Database` instance | ||
@@ -154,0 +154,0 @@ ### Return: |
@@ -7,3 +7,3 @@ 'use strict'; | ||
exports.relationships = exports.schema = exports.tables = undefined; | ||
exports.default = collimator; | ||
exports.inspect = inspect; | ||
@@ -45,8 +45,8 @@ var _bluebird = require('bluebird'); | ||
* | ||
* @function collimator | ||
* @param {Promise.<Database>} db - The pg-promise connection | ||
* @function collimator.inspect | ||
* @param {Database} db - A pg-promise `Database` instance | ||
* @returns {Promise.<Object>} A promise that will resolve to the information for each table | ||
*/ | ||
function collimator(db) { | ||
var inspect = function inspect(table) { | ||
function inspect(db) { | ||
var inspectors = function inspectors(table) { | ||
return _bluebird2.default.props((0, _ramda.merge)(table, { | ||
@@ -58,3 +58,3 @@ schema: (0, _schema2.default)(db, table.name), | ||
return (0, _tables2.default)(db).map(inspect); | ||
return (0, _tables2.default)(db).map(inspectors); | ||
} | ||
@@ -61,0 +61,0 @@ |
@@ -35,3 +35,3 @@ 'use strict'; | ||
* @function collimator.relationships | ||
* @param {Promise.<Database>} db - The pg-promise connection | ||
* @param {Database} db - A pg-promise `Database` instance | ||
* @param {String} name - The name of the table to get the relationship definitions for | ||
@@ -38,0 +38,0 @@ * @returns {Promise.<Object>} A promise that will resolve to the relationship definitions for the given table |
@@ -29,3 +29,3 @@ 'use strict'; | ||
* @function collimator.schema | ||
* @param {Promise.<Database>} db - The pg-promise connection | ||
* @param {Database} db - A pg-promise `Database` instance | ||
* @param {String} name - The name of the table to get the schema of | ||
@@ -80,25 +80,26 @@ * @returns {Promise.<Object>} A promise that will resolve to the schema for the given table | ||
var TYPES = { | ||
bigserial: 'integer', | ||
boolean: 'boolean', | ||
'character varying': 'string', | ||
character: 'string', | ||
date: 'string', | ||
bigint: 'integer', | ||
'double precision': 'number', | ||
integer: 'integer', | ||
json: 'object', | ||
jsonb: 'object', | ||
numeric: 'number', | ||
real: 'number', | ||
smallint: 'integer', | ||
smallserial: 'integer', | ||
serial: 'integer', | ||
text: 'string', | ||
'time without time zone': 'string', | ||
'timestamp without time zone': 'string' | ||
bigserial: { type: 'integer' }, | ||
boolean: { type: 'boolean' }, | ||
character: { type: 'string' }, | ||
date: { type: 'string' }, | ||
bigint: { type: 'integer' }, | ||
integer: { type: 'integer' }, | ||
json: { type: 'object' }, | ||
jsonb: { type: 'object' }, | ||
numeric: { type: 'number' }, | ||
real: { type: 'number' }, | ||
smallint: { type: 'integer' }, | ||
smallserial: { type: 'integer' }, | ||
serial: { type: 'integer' }, | ||
text: { type: 'string' }, | ||
'character varying': { type: 'string' }, | ||
'double precision': { type: 'number' }, | ||
'time without time zone': { type: 'string', format: 'date-time' }, | ||
'time with time zone': { type: 'string', format: 'date-time' }, | ||
'timestamp without time zone': { type: 'string', format: 'date-time' }, | ||
'timestamp with time zone': { type: 'string', format: 'date-time' } | ||
}; | ||
return _defineProperty({}, column.name, { | ||
type: TYPES[column.type] | ||
}); | ||
return _defineProperty({}, column.name, TYPES[column.type]); | ||
} | ||
@@ -105,0 +106,0 @@ |
@@ -25,3 +25,3 @@ 'use strict'; | ||
* @function collimator.tables | ||
* @param {Promise.<Database>} db - The pg-promise connection | ||
* @param {Database} db - A pg-promise `Database` instance | ||
* @returns {Promise.<Array<Object>>} A promise that will resolve to table | ||
@@ -28,0 +28,0 @@ * information for the given database |
@@ -80,3 +80,3 @@ { | ||
}, | ||
"version": "4.0.1" | ||
"version": "4.1.0" | ||
} |
@@ -35,7 +35,7 @@ <div id="badges" align="center"></div> | ||
The top-level Collimator functions (`tables`, `schema` and `relationships`) accept a [pg-promise][pg-promise] connection as their first argument, and return a promise. For further guidance, please refer to the [examples][examples] and [API Documentation][api-docs]. | ||
The top-level Collimator functions (`tables`, `schema` and `relationships`) accept a [pg-promise][pg-promise] `Database` instance as their first argument, and return a promise. For further guidance, please refer to the [examples][examples] and [API Documentation][api-docs]. | ||
[pg-promise]: https://www.npmjs.com/package/pg-promise | ||
[examples]: https://github.com/radify/collimator/tree/master/examples | ||
[api-docs]: https://github.com/radify/collimator/blob/master/api.md | ||
[api-docs]: https://github.com/radify/collimator/blob/master/docs/API.md | ||
@@ -42,0 +42,0 @@ ### Changelog |
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
31311
26.2%29
16%435
30.63%2
-33.33%0
-100%