How to use sequelize - 10 common examples

To help you get started, we’ve selected a few sequelize 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 flow-typed / flow-typed / definitions / npm / sequelize_v4.x.x / flow_v0.42.x- / test_sequelize.js View on Github external
if (typeof val === "string") {
        val = val.toLowerCase();
      } else {
        throw new Error("email must be a string");
      }
      this.setDataValue("email", val);
    }
  }
}, {
  timestamps: false,
  indexes: [
    {
      name: "DefineOptionsIndexesTest_lower_email",
      unique: true,
      fields: [
        Sequelize.fn("LOWER", Sequelize.col("email"))
      ]
    }
  ]
} );

//
//  Transaction
// ~~~~~~~~~~~~~
//
//  https://github.com/sequelize/sequelize/blob/v3.4.1/test/integration/transaction.test.js
//

s.transaction().then( function( t ) {

  t.commit();
  t.rollback();
github feathers-plus / generator-feathers-plus / test / name-space.test-expected / src1 / services / c-1 / nedb-6 / nedb-6.sequelize.js View on Github external
/* eslint quotes: 0 */
// Defines Sequelize model for service `nedb6`. (Can be re-generated.)
const merge = require('lodash.merge');
const Sequelize = require('sequelize');
// eslint-disable-next-line no-unused-vars
const DataTypes = Sequelize.DataTypes;
// !code: imports // !end
// !code: init // !end

let moduleExports = merge({},
  // ! code: sequelize_model
  {},
  // !end
  // !code: moduleExports // !end
);

// !code: exports // !end
module.exports = moduleExports;

// !code: funcs // !end
// !code: end // !end
github feathers-plus / generator-feathers-plus / test / cumulative-1-no-semicolons.test-expected / src1 / services / users-1 / users-1.sequelize.js View on Github external
/* eslint quotes: 0 */
// Defines Sequelize model for service `users1`. (Can be re-generated.)
const merge = require('lodash.merge')
const Sequelize = require('sequelize')
// eslint-disable-next-line no-unused-vars
const DataTypes = Sequelize.DataTypes
// !code: imports // !end
// !code: init // !end

// Your model may need the following fields:
//   email:      { type: DataTypes.STRING, allowNull: false, unique: true },
//   password:   { type: DataTypes.STRING, allowNull: false },
//   auth0Id:    { type: DataTypes.STRING },
//   googleId:   { type: DataTypes.STRING },
//   facebookId: { type: DataTypes.STRING },
//   githubId:   { type: DataTypes.STRING },
let moduleExports = merge({},
  // ! code: sequelize_model
  {},
  // !end
  // !code: moduleExports // !end
)
github feathers-plus / generator-feathers-plus / test / cumulative-2-sequelize-services.test-expected / src1 / services / users-1 / users-1.sequelize.js View on Github external
/* eslint quotes: 0 */
// Defines Sequelize model for service `users1`. (Can be re-generated.)
const merge = require('lodash.merge');
const Sequelize = require('sequelize');
// eslint-disable-next-line no-unused-vars
const DataTypes = Sequelize.DataTypes;
// !code: imports // !end
// !code: init // !end

// Your model may need the following fields:
//   email:      { type: DataTypes.STRING, allowNull: false, unique: true },
//   password:   { type: DataTypes.STRING, allowNull: false },
//   auth0Id:    { type: DataTypes.STRING },
//   googleId:   { type: DataTypes.STRING },
//   facebookId: { type: DataTypes.STRING },
//   githubId:   { type: DataTypes.STRING },
let moduleExports = merge({},
  // ! code: sequelize_model
  {},
  // !end
  // !code: moduleExports // !end
);
github feathers-plus / generator-feathers-plus / test-expands / name-space.test-expected / src1 / services / a-1 / b-1 / nedb-4 / nedb-4.sequelize.js View on Github external
/* eslint quotes: 0 */
// Defines Sequelize model for service `nedb4`. (Can be re-generated.)
const merge = require('lodash.merge');
const Sequelize = require('sequelize');
// eslint-disable-next-line no-unused-vars
const DataTypes = Sequelize.DataTypes;
// !code: imports // !end
// !code: init // !end

let moduleExports = merge({},
  // ! code: sequelize_model
  {
    id: {
      type: DataTypes.INTEGER,
      autoIncrement: true,
      primaryKey: true
    },
    nedb2Id: {
      type: DataTypes.INTEGER
    }
  },
  // !end
github salesforce / refocus / tests / api / v1 / users / patch.js View on Github external
before((done) => {
      let adminProfileId = '';
      User.findOne({
        where: {
          name: {
            [Op.iLike]: OBAdminUser.name,
          },
        },
      })
      .then((OBAdminUser) => adminProfileId = OBAdminUser.profileId)

      // create a normal user
      .then(() => User.create({
        profileId: profileOneId,
        name: userZero,
        email: userZero,
        password: userZero,
      }))

      // create a normal user
      .then(() => User.create({
        profileId: profileOneId,
github flow-typed / flow-typed / definitions / npm / sequelize_v4.x.x / flow_v0.42.x- / test_sequelize.js View on Github external
Sequelize.BLOB( 'tiny' );
Sequelize.BLOB( 'medium' );
Sequelize.BLOB( { length : 'medium' } );
Sequelize.BLOB( 'long' );
Sequelize.ARRAY( Sequelize.STRING );
Sequelize.ARRAY( Sequelize.STRING( 100 ) );
Sequelize.ARRAY( Sequelize.INTEGER );
Sequelize.ARRAY( Sequelize.HSTORE );
Sequelize.ARRAY( Sequelize.ARRAY( Sequelize.STRING ) );
Sequelize.ARRAY( Sequelize.TEXT );
Sequelize.ARRAY( Sequelize.DATE );
Sequelize.ARRAY( Sequelize.BOOLEAN );
Sequelize.ARRAY( Sequelize.DECIMAL );
Sequelize.ARRAY( Sequelize.DECIMAL( 6 ) );
Sequelize.ARRAY( Sequelize.DECIMAL( 6, 4 ) );
Sequelize.ARRAY( Sequelize.DOUBLE );
Sequelize.ARRAY( Sequelize.REAL );
Sequelize.ARRAY( Sequelize.JSON );
Sequelize.ARRAY( Sequelize.JSONB );
Sequelize.GEOMETRY;
Sequelize.GEOMETRY( 'POINT' );
Sequelize.GEOMETRY( 'LINESTRING' );
Sequelize.GEOMETRY( 'POLYGON' );
Sequelize.GEOMETRY( 'POINT', 4326 );
Sequelize.VIRTUAL;
Sequelize.VIRTUAL( Sequelize.STRING );
Sequelize.VIRTUAL( Sequelize.DATE , ['property1', 'property2']);
new Sequelize.VIRTUAL( Sequelize.STRING );
new Sequelize.VIRTUAL( Sequelize.DATE , ['property1', 'property2']);

//
//  Deferrable
github flow-typed / flow-typed / definitions / npm / sequelize_v4.x.x / flow_v0.42.x- / test_sequelize.js View on Github external
Sequelize.BLOB( 'long' );
Sequelize.ARRAY( Sequelize.STRING );
Sequelize.ARRAY( Sequelize.STRING( 100 ) );
Sequelize.ARRAY( Sequelize.INTEGER );
Sequelize.ARRAY( Sequelize.HSTORE );
Sequelize.ARRAY( Sequelize.ARRAY( Sequelize.STRING ) );
Sequelize.ARRAY( Sequelize.TEXT );
Sequelize.ARRAY( Sequelize.DATE );
Sequelize.ARRAY( Sequelize.BOOLEAN );
Sequelize.ARRAY( Sequelize.DECIMAL );
Sequelize.ARRAY( Sequelize.DECIMAL( 6 ) );
Sequelize.ARRAY( Sequelize.DECIMAL( 6, 4 ) );
Sequelize.ARRAY( Sequelize.DOUBLE );
Sequelize.ARRAY( Sequelize.REAL );
Sequelize.ARRAY( Sequelize.JSON );
Sequelize.ARRAY( Sequelize.JSONB );
Sequelize.GEOMETRY;
Sequelize.GEOMETRY( 'POINT' );
Sequelize.GEOMETRY( 'LINESTRING' );
Sequelize.GEOMETRY( 'POLYGON' );
Sequelize.GEOMETRY( 'POINT', 4326 );
Sequelize.VIRTUAL;
Sequelize.VIRTUAL( Sequelize.STRING );
Sequelize.VIRTUAL( Sequelize.DATE , ['property1', 'property2']);
new Sequelize.VIRTUAL( Sequelize.STRING );
new Sequelize.VIRTUAL( Sequelize.DATE , ['property1', 'property2']);

//
//  Deferrable
// ~~~~~~~~~~~~
//
//  https://github.com/sequelize/sequelize/blob/v3.4.1/test/integration/sequelize/deferrable.test.js
github flow-typed / flow-typed / definitions / npm / sequelize_v4.x.x / flow_v0.42.x- / test_sequelize.js View on Github external
//
//  DataTypes
// ~~~~~~~~~~~
//
//  https://github.com/sequelize/sequelize/blob/v3.4.1/test/unit/sql/data-types.test.js
//

Sequelize.STRING;
Sequelize.STRING( 1234 );
Sequelize.STRING( { length : 1234 } );
Sequelize.STRING( 1234 ).BINARY;
Sequelize.STRING.BINARY;
Sequelize.TEXT;
Sequelize.TEXT( 'tiny' );
Sequelize.TEXT( { length : 'tiny' } );
Sequelize.TEXT( 'medium' );
Sequelize.TEXT( 'long' );
Sequelize.CHAR;
Sequelize.CHAR( 12 );
Sequelize.CHAR( { length : 12 } );
Sequelize.CHAR( 12 ).BINARY;
Sequelize.CHAR.BINARY;
Sequelize.BOOLEAN;
Sequelize.DATE;
Sequelize.DATE(6);
Sequelize.UUID;
Sequelize.UUIDV1;
Sequelize.UUIDV4;
Sequelize.NOW;
Sequelize.INTEGER;
Sequelize.INTEGER.UNSIGNED;
github flow-typed / flow-typed / definitions / npm / sequelize_v4.x.x / flow_v0.42.x- / test_sequelize.js View on Github external
//  DataTypes
// ~~~~~~~~~~~
//
//  https://github.com/sequelize/sequelize/blob/v3.4.1/test/unit/sql/data-types.test.js
//

Sequelize.STRING;
Sequelize.STRING( 1234 );
Sequelize.STRING( { length : 1234 } );
Sequelize.STRING( 1234 ).BINARY;
Sequelize.STRING.BINARY;
Sequelize.TEXT;
Sequelize.TEXT( 'tiny' );
Sequelize.TEXT( { length : 'tiny' } );
Sequelize.TEXT( 'medium' );
Sequelize.TEXT( 'long' );
Sequelize.CHAR;
Sequelize.CHAR( 12 );
Sequelize.CHAR( { length : 12 } );
Sequelize.CHAR( 12 ).BINARY;
Sequelize.CHAR.BINARY;
Sequelize.BOOLEAN;
Sequelize.DATE;
Sequelize.DATE(6);
Sequelize.UUID;
Sequelize.UUIDV1;
Sequelize.UUIDV4;
Sequelize.NOW;
Sequelize.INTEGER;
Sequelize.INTEGER.UNSIGNED;
Sequelize.INTEGER.UNSIGNED.ZEROFILL;
Sequelize.INTEGER( 11 );

sequelize

Sequelize is a promise-based Node.js ORM tool for Postgres, MySQL, MariaDB, SQLite, Microsoft SQL Server, Amazon Redshift and Snowflake’s Data Cloud. It features solid transaction support, relations, eager and lazy loading, read replication and more.

MIT
Latest version published 28 days ago

Package Health Score

95 / 100
Full package analysis