1.0.0 • Published 6 years ago

@fxjs/orm-plugin-pool v1.0.0

Weekly downloads
2
License
ISC
Repository
-
Last release
6 years ago

orm-plugin-pool

NPM version

Pool Plugin for @fxjs/orm

Installation

fibjs --install @fxjs/orm @fxjs/orm-plugin-pool

Usage

const ORM = require('@fxjs/orm');
const ORMPluginPool = require('@fxjs/orm-plugin-pool')

const definitions = [
    (orm) => {
        orm.define('user', {}, {})
    },
    (orm) => {
        orm.define('role', {}, {})
    }
]

const pool = ORM.getPool({
    connection: 'sqlite:test.db',
    definitions: definitions,

    maxszie: 10,
    timeout: 1000,
    retry: 3
});

pool(orm => {
    orm.user.createSync({/* ... */})
});

or use it as plugin

const ORM = require('@fxjs/orm');
const ORMPluginPool = require('@fxjs/orm-plugin-pool')

const orm = ORM.connectSync('sqlite:test.db');

// use it to enable `orm.$pool`
orm.use(ORMPluginPool, {
    definitions: definitions,
    maxszie: 10,
    timeout: 1000,
    retry: 3
});

orm.$pool(orm => {
    orm.user.createSync({/* ... */})
})