@matteo.collina/assets-pg
Manage Assets as a module, with node and postgres
Last updated 2 years ago by matteo.collina .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @matteo.collina/assets-pg 
SYNC missed versions from official npm registry.

assets-pg

Manage Assets, with node and postgres

An asset can be in three states: 'wait', 'operational' and 'error'.

Install

npm install @matteo.collina/assets-pg --save

API


buildAssets(connectionString)

The factory for the assets module, you can just pass through a pg connection string.

Example:

var connString = 'postgres://localhost/assets_tests'
var assets = require('@matteo.collina/assets-pg')(connString)

assets.put(object, callback(err, asset))

Adds or updates an asset. An asset can have three properties:

  1. the 'id', which needs to be set only for existing assets
  2. the 'name'
  3. the 'status', which can be any of 'wait', 'operational' and 'error'.

Validation is provided by ajv, and a new createError.UnprocessableEntity() (from http-errors) with the ajv errors attached to the details.

The returned asset includes the id, if missing.


assets.get(id, callback(err, asset))

Fetches an assets, returns a new createError.NotFound() (from http-errors) if not present.


assets.createSchema(callback(err))

Create the schema in PostgreSQL for this module.


assets.dropSchema(callback(err))

Drop the schema in PostgreSQL for this module.


assets.end()

Ends the PG connection pool.

License

MIT

Current Tags

  • 4.0.0                                ...           latest (2 years ago)

7 Versions

  • 4.0.0                                ...           2 years ago
  • 3.0.0                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 2.0.0                                ...           4 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 7
This Month 7
Last Day 0
Last Week 7
Last Month 15
Dependencies (3)
Dev Dependencies (3)

Copyright 2014 - 2017 © taobao.org |