How to use the sequelize.DataTypes function in sequelize

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 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 rochejul / sequelize-mocking / lib / sequelize-mocking.js View on Github external
static copyModel(sequelizeInstance, model) {
        class TempModel extends Sequelize.Model {
        }

        let newModel = TempModel.init(
            _.merge({ }, model.rawAttributes),
            _.merge({ }, model.options, { 'sequelize': sequelizeInstance, 'modelName': model.name })
        );

        // Let's recreate a new instance of the datatype
        for (let att of _.values(newModel.rawAttributes)) {
            att.type = new Sequelize.DataTypes[att.type.key]();
        }

        return newModel;
    }
github feathers-plus / generator-feathers-plus / examples / js / 07-fakes / feathers-app / src / services / teams / teams.sequelize.js View on Github external
/* eslint quotes: 0 */
// Defines Sequelize model for service `teams`. (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
    },
    name: {
      type: DataTypes.TEXT,
      allowNull: false
    },
    members: {
github Zooz / predator / src / database / sequlize-handler / migrations / 02_tests_processor_id.js View on Github external
module.exports.up = async (query, DataTypes) => {
    let testsTable = await query.describeTable('tests');

    if (!testsTable.processor_id) {
        await query.addColumn(
            'tests', 'processor_id',
            Sequelize.DataTypes.UUID);
    }
};
github AlphaConsole / AlphaConsoleBot / src / Models / index.js View on Github external
models.forEach(f => {
      if (!f.endsWith(".js") || f === "index.js") return;

      try {
        const modelName = f.split(".")[0];
        modelList[modelName] = require(`./${modelName}`)(
          sequelize,
          Sequelize.DataTypes
        );
      } catch (e) {
        client.logError(`Unable to load model ${f}: ${e}`);
      }
    });
github prayuditb / express-backend-sequelize / src / models / user.model.ts View on Github external
export default (sequelize: Sequelize.Sequelize) => {
  User.init({
    email: { field: "email", type: Sequelize.DataTypes.STRING, unique: { name: "email", msg: "email already exist" }},
    phone_number: { field: "phone_number", type: Sequelize.DataTypes.STRING, unique: { name: "phone_number", msg: "phone number already exist" }},
    first_name: { field: "first_name", type: Sequelize.DataTypes.STRING },
    last_name: { field: "last_name", type: Sequelize.DataTypes.STRING },
    password: { field: "password", type: Sequelize.DataTypes.STRING },
    gender: { field: "gender", type: Sequelize.DataTypes.STRING },
    birth_date: { field: "birth_date", type: Sequelize.DataTypes.DATE },
    forgot_password: { field: "forgot_password", type: Sequelize.DataTypes.STRING },
    created_at: { field: "created_at", type: Sequelize.DataTypes.DATE },
    updated_at: { field: "updated_at", type: Sequelize.DataTypes.DATE },
    deleted_at: { field: "deleted_at", type: Sequelize.DataTypes.DATE },
  }, {
    sequelize,
    timestamps: true,
    paranoid: true,
    underscored: true,
    tableName: "users"

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 27 days ago

Package Health Score

95 / 100
Full package analysis