New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

collimator

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

collimator - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

24

api.md

@@ -5,2 +5,26 @@

## collimator(db)
Inspect all enumerable table in a database, and return a promise that will
resolve to information about each table.
The resolved value will be an array of objects, each containing the
following properties:
- `name` - The name of the enumerated table
- `primaryKeys` - An array of column names containing primary keys
- `schema` - A JSON Schema v4 document that can be used to validated objects
that are candidates for insertion into this table
- `relationships` - Relationship information, determined by foreign key
contraints. See `collimator.relationships` for further information on the
structure of this data.
### Params:
* **Promise.\<Database>** *db* - The pg-promise connection
### Return:
* **Promise.\<Object>** A promise that will resolve to the information for each table
<!-- End src/collimator.js -->

@@ -7,0 +31,0 @@

3

CHANGELOG.md

@@ -5,2 +5,5 @@ # Change Log

## 2.0.0 - 2015-09-10
* Fully inspect database by default when invoking `collimator` directly
## 2.0.0 - 2015-09-09

@@ -7,0 +10,0 @@ * Aggregate primary keys into an array

2

package.json
{
"name": "collimator",
"version": "2.0.0",
"version": "2.1.0",
"description": "Reflection & Introspection for PostgreSQL Databases",

@@ -5,0 +5,0 @@ "main": "src/collimator.js",

describe('collimator', function() {
var collimator = require('../src/collimator');
var bluebird = require('bluebird');

@@ -9,2 +10,28 @@ it('exports inspectors', function() {

});
it('describes the entire database when invoked directly', function(done) {
var tables = bluebird.defer();
var schema = bluebird.defer();
var relationships = bluebird.defer();
spyOn(collimator, 'tables').and.returnValue(tables.promise);
spyOn(collimator, 'schema').and.returnValue(schema.promise);
spyOn(collimator, 'relationships').and.returnValue(relationships.promise);
collimator('mockDb')
.then(function(result) {
expect(collimator.tables).toHaveBeenCalledWith('mockDb');
expect(collimator.schema).toHaveBeenCalledWith('mockDb', 'mockTable');
expect(collimator.relationships).toHaveBeenCalledWith('mockDb', 'mockTable');
expect(result).toEqual([
{ name: 'mockTable', schema: 'mockSchema', relationships: 'mockRelationships' }
]);
})
.then(done);
tables.resolve([{name: 'mockTable'}]);
schema.resolve('mockSchema');
relationships.resolve('mockRelationships');
});
});
'use strict';
module.exports = {
tables: require('./inspectors/tables.js'),
schema: require('./inspectors/schema.js'),
relationships: require('./inspectors/relationships.js')
};
var bluebird = require('bluebird');
var R = require('ramda');
/**
* Inspect all enumerable table in a database, and return a promise that will
* resolve to information about each table.
*
* The resolved value will be an array of objects, each containing the
* following properties:
*
* - `name` - The name of the enumerated table
* - `primaryKeys` - An array of column names containing primary keys
* - `schema` - A JSON Schema v4 document that can be used to validated objects
* that are candidates for insertion into this table
* - `relationships` - Relationship information, determined by foreign key
* contraints. See `collimator.relationships` for further information on the
* structure of this data.
*
* @function collimator
* @param {Promise.<Database>} db - The pg-promise connection
* @returns {Promise.<Object>} A promise that will resolve to the information for each table
*/
function collimator(db) {
return collimator.tables(db)
.map(function(table) {
return bluebird.props(R.merge(table, {
schema: collimator.schema(db, table.name),
relationships: collimator.relationships(db, table.name)
}));
});
}
collimator.tables = require('./inspectors/tables');
collimator.schema = require('./inspectors/schema');
collimator.relationships = require('./inspectors/relationships');
module.exports = collimator;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc