How to use the mysql.hasOwnProperty function in mysql

To help you get started, we’ve selected a few mysql 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 Mog-Inc / easy-mysql / test / common.js View on Github external
var mysql = require('mysql');
var assert = require('assert');

var lib_dir = 'lib';
if (process.env.EASY_MYSQL_JSCOV) {
    lib_dir = 'lib-cov';
}

var EasyMySQL = require('../' + lib_dir + '/easy_mysql');
var EasyClient = require('../' + lib_dir + '/easy_client');
var easy_pool = require('../' + lib_dir + '/easy_pool');

var conn_method = 'createConnection';
if (mysql.hasOwnProperty('createClient')) {
    conn_method = 'createClient';
}

function clone(object) {
    var ret = {};
    Object.keys(object).forEach(function (val) {
        ret[val] = object[val];
    });
    return ret;
}

function random_string() {
    return 'str' + Math.floor(Math.random() * 10000000000);
}

try {
github Mog-Inc / easy-mysql / lib / easy_client.js View on Github external
EasyClient.fetch = function (settings, cb) {
    if (settings.pool) {
        get_client_from_pool(settings.pool, cb);
    } else if (settings.use_easy_pool) {
        var pool = easy_pool.fetch(settings);
        get_client_from_pool(pool, cb);
    } else {
        var client;
        if (mysql.hasOwnProperty('createConnection')) {
            client = mysql.createConnection(settings);
        } else if (mysql.hasOwnProperty('createClient')) {
            client = mysql.createClient(settings);
        } else {
            console.log("\nEasyMySQL [WARNING]: node-mysql 0.9.1 support is deprecated.\n");
            client = new mysql.Client(settings);
            client.connect();
        }
        cb(null, new EasyClient(client));
    }
};
github Mog-Inc / easy-mysql / lib / easy_pool.js View on Github external
var pool_module = require('generic-pool');
var mysql = require('mysql');

var conn_method = 'createConnection';
if (mysql.hasOwnProperty('createClient')) {
    conn_method = 'createClient';
}

/** @ignore */
var pool = {
    /** @ignore */
    create: function (settings) {
        return pool_module.Pool({
            name: 'mysql_' + settings.database,

            create: function (callback) {
                var client;
                if (mysql.hasOwnProperty(conn_method)) {
                    client = mysql[conn_method](settings);
                } else {
                    console.log("\nEasyMySQL [WARNING]: node-mysql 0.9.1 support is deprecated.\n");
github Mog-Inc / easy-mysql / lib / easy_client.js View on Github external
EasyClient.fetch = function (settings, cb) {
    if (settings.pool) {
        get_client_from_pool(settings.pool, cb);
    } else if (settings.use_easy_pool) {
        var pool = easy_pool.fetch(settings);
        get_client_from_pool(pool, cb);
    } else {
        var client;
        if (mysql.hasOwnProperty('createConnection')) {
            client = mysql.createConnection(settings);
        } else if (mysql.hasOwnProperty('createClient')) {
            client = mysql.createClient(settings);
        } else {
            console.log("\nEasyMySQL [WARNING]: node-mysql 0.9.1 support is deprecated.\n");
            client = new mysql.Client(settings);
            client.connect();
        }
        cb(null, new EasyClient(client));
    }
};
github Mog-Inc / easy-mysql / lib / easy_pool.js View on Github external
create: function (callback) {
                var client;
                if (mysql.hasOwnProperty(conn_method)) {
                    client = mysql[conn_method](settings);
                } else {
                    console.log("\nEasyMySQL [WARNING]: node-mysql 0.9.1 support is deprecated.\n");
                    client = new mysql.Client(settings);
                    client.connect();
                }
                callback(null, client);
            },