How to use node-sql-2 - 4 common examples

To help you get started, we’ve selected a few node-sql-2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github doxout / anydb-sql / anydb-sql.js View on Github external
module.exports = function (opt) {
    var pool,
        db = {},
        dialect = extractDialect(opt.url);

    sql.setDialect(dialect);

    db.open = function() {
        if (pool) return; // already open
        if (dialect == 'sqlite') {
            try {
                var SQLitePool = require('./lib/sqlite-pool');
                pool = new SQLitePool(opt.url, opt.connections);
            } catch (e) {
                throw new Error("Unable to load sqlite pool: " + e.message);
            }
        }
        else {
            pool = new AnyDBPool(opt.url, opt.connections);
        }
        pool._mainpool = true;
    };
github doxout / anydb-sql / anydb-sql.js View on Github external
db.define = function (opt) {
        var t = extendedTable(sql.define.apply(sql, arguments), opt);
        db.models[opt.name] = t;
        return t;
    };
github doxout / anydb-sql / anydb-sql.js View on Github external
};


        return extQuery;
    }


    db.define = function (opt) {
        var t = extendedTable(sql.define.apply(sql, arguments), opt);
        db.models[opt.name] = t;
        return t;
    };

    db.functions = sql.functions;

    db.makeFunction = sql.functionCallCreator;

    db.close = function() {
        if (pool) pool.close.apply(pool, arguments);
        pool = null;
    };

    db.begin = function() {
        var tx = pool.begin();
        return wrapTransaction(tx);
    };

    db.transaction = function(f) {
        return P.try(function() {
            return wrapTransaction(pool.begin());
        }).then(function(tx) {
            return P.try(f, tx).then(function(res) {
github doxout / anydb-sql / anydb-sql.js View on Github external
extQuery.selectDeep = function() {
            return extQuery.select(db.allOf.apply(db, arguments));
        };


        return extQuery;
    }


    db.define = function (opt) {
        var t = extendedTable(sql.define.apply(sql, arguments), opt);
        db.models[opt.name] = t;
        return t;
    };

    db.functions = sql.functions;

    db.makeFunction = sql.functionCallCreator;

    db.close = function() {
        if (pool) pool.close.apply(pool, arguments);
        pool = null;
    };

    db.begin = function() {
        var tx = pool.begin();
        return wrapTransaction(tx);
    };

    db.transaction = function(f) {
        return P.try(function() {
            return wrapTransaction(pool.begin());

node-sql-2

sql builder

MIT
Latest version published 4 years ago

Package Health Score

49 / 100
Full package analysis

Similar packages