How to use the mysql-utilities.introspection function in mysql-utilities

To help you get started, we’ve selected a few mysql-utilities 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 postor / mysql-restful-api / cli.js View on Github external
.then((connection)=>{
  // Mix-in for Data Access Methods and SQL Autogenerating Methods
  mysqlUtilities.upgrade(connection)
  // Mix-in for Introspection Methods
  mysqlUtilities.introspection(connection)
  mysqlConnection = connection

  return Promise.promisify(connection.tables,{context: connection})()
})
//遍历表并生成model和router文件
github thejibz / graphql-compose-mysql / src / composeWithMysql.js View on Github external
throw new Error("You must provide a 'mysqlConfig' argument for the database.")
            }

            if (!opts.prefix) {
                opts.prefix = ""
            }

            PREFIX = Object.freeze(opts.prefix)

            // TODO optimize schema creation (use a pool instead of a single connection ?)
            const mysqlConnection = mysql.createConnection(opts.mysqlConfig)

            // Mix-in for Data Access Methods and SQL Autogenerating Methods
            mysqlUtilities.upgrade(mysqlConnection)
            // Mix-in for Introspection Methods
            mysqlUtilities.introspection(mysqlConnection)

            // initialize the graphQL schema
            const schemaComposer = new SchemaComposer()

            const mysqlTablesNames = await _getMysqlTablesNames(mysqlConnection)

            return Promise.all(mysqlTablesNames.map(async mysqlTableName => {
                // initialize the graphql type built from the mysql table
                const gqlTC = schemaComposer.TypeComposer.create({
                    name: _clearNameForType(mysqlTableName),
                })

                // add local fields
                const fields = await _buildGqlFieldsFromMysqlTable(mysqlConnection, mysqlTableName)
                gqlTC.addFields(fields)
github mike-jung / node-web-starter / database / database_mysql.js View on Github external
pool.getConnection((err, conn) => {

            if (err) {
                console.log('Error in fetching database connection -> ' + err);
                callback(err, null);

                return;
            }

            mysqlUtilities.upgrade(conn);
            mysqlUtilities.introspection(conn);

            conn.fields(tableName, (err, fields) => {
                if (conn) {
                    conn.release();
                }

                if (err) {
                    console.log('Error in fetching fields -> ' + err);
                    callback(err, null);
                    return;
                }

                callback(null, fields);
            });
 
        });

mysql-utilities

Utilities for node-mysql driver with specialized result types, introspection and other helpful functionality.

MIT
Latest version published 2 years ago

Package Health Score

51 / 100
Full package analysis