Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sk2

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sk2

knex with sequelize query

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30
increased by15.38%
Maintainers
1
Weekly downloads
 
Created
Source

sk2

NPM version NPM downloads Dependency Status Build Status Coverage Status Greenkeeper badge

sk2 is used for extend sequelize with knex.

Installation

npm install sk2

Example

const sk2 = require('sk2');
const Sequelize = require('sequelize');

const sequelize = new Sequelize('db_name', 'root', 'password', {
  dialect: 'mysql'
});

async function main() {
  const knex = sk2(sequelize);

  await knex.schema
    .createTable('users', function(table) {
      table.increments('id');
      table.string('user_name');
    })
    .createTable('accounts', function(table) {
      table.increments('id');
      table.string('account_name');
      table
        .integer('user_id')
        .unsigned()
        .references('users.id');
    });

  const rows = knex('users').insert({ user_name: 'Tim' });

  await knex('accounts').insert({
    account_name: 'sk2',
    user_id: rows[0]
  });

  const users = await knex('users')
    .join('accounts', 'users.id', 'accounts.user_id')
    .select('users.user_name as user', 'accounts.account_name as account');

  console.log(users);
  // [{ user: 'Tim', account: 'sk2' }]
}

main().then(() => {
  sequelize.close();
});

License

MIT

Keywords

FAQs

Package last updated on 06 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc