mypg-tools

0.1.0 • Public • Published

mypg-tools

Tools for mypg lib.

API

Methods require context (this) to have user property for audit reasons (convention of mypg).

findOrCreate.build(tableName, discriminantName)

Builds function findOrCreate(discriminantValue) which promises extraction or creation of record which match discrimination condition.

var findOrCreate = tools.findOrCreate.build('products', 'name');
findOrCreate('milk').then(console.log);

associate.build(tableName, masterColumnName, slaveColumnName);

Builds function associate(masterValue, slaveValuesArray) which does association (many to many) of certain record with given children.

var associate = tools.associate.build('ad_photos', 'ad_id', 'photo_id');
associate(12, [55, 12, 32]).then(function () {
    console.log('12th ad was associated with 55th, 12th and 32d photos.');
});

License

BSD

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i mypg-tools

    Weekly Downloads

    0

    Version

    0.1.0

    License

    BSD

    Last publish

    Collaborators

    • titarenko