How to use the sequelize.ENUM 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 joshwcomeau / tinkersynth / src / server / database.js View on Github external
// Instead, a unique ID is created on the client and stored in localStorage.
// There is no authorization process; I use this model purely to group art
// together, so that I can easily find all pieces created by a specific user
// ID.
export const User = sequelize.define('user', {
  id: { type: Sequelize.UUID, primaryKey: true },
  name: { type: Sequelize.STRING, allowNull: true },
  email: Sequelize.STRING,
});

export const Order = sequelize.define('order', {
  id: {
    type: Sequelize.INTEGER,
    primaryKey: true,
  },
  format: Sequelize.ENUM('print', 'vector', 'combo'),
  size: Sequelize.ENUM('small', 'medium', 'large'),
  cost: Sequelize.INTEGER,
  artParams: Sequelize.JSON,
  chargeId: Sequelize.STRING,
  shipped: { type: Sequelize.BOOLEAN, allowNull: true },
  // Shipping address
  shipTo: Sequelize.STRING,
  streetAddress: Sequelize.STRING,
  city: Sequelize.STRING,
  state: Sequelize.STRING,
  country: Sequelize.STRING,
  zipCode: Sequelize.STRING,
  // Image URLs
  svgUrl: { type: Sequelize.STRING, allowNull: true },
  pngUrlOpaque: { type: Sequelize.STRING, allowNull: true },
  pngUrlTransparent: { type: Sequelize.STRING, allowNull: true },
github OriginProtocol / origin / dapps / shop / backend / data / db.js View on Github external
type: Sequelize.TEXT
    }
  },
  {
    // options
  }
)

const Discounts = sequelize.define(
  'discounts',
  {
    network_id: {
      type: Sequelize.INTEGER
    },
    status: {
      type: Sequelize.ENUM('active', 'inactive')
    },
    code: {
      type: Sequelize.STRING
    },
    discountType: {
      type: Sequelize.ENUM('fixed', 'percentage')
    },
    value: {
      type: Sequelize.INTEGER
    },
    maxUses: {
      type: Sequelize.INTEGER
    },
    onePerCustomer: {
      type: Sequelize.BOOLEAN
    },
github simonrenoult / nodejs-application-architecture / index.js View on Github external
// Schemas and models
const Product = sequelize.define("product", {
  name: Sequelize.STRING,
  price: Sequelize.INTEGER,
  weight: Sequelize.INTEGER
});

const productSchema = Joi.object().keys({
  name: Joi.required(),
  price: Joi.required(),
  weight: Joi.required()
});

const Order = sequelize.define("order", {
  status: {
    type: Sequelize.ENUM("pending", "cancelled", "paid"),
    defaultValue: "pending"
  },
  shipment_amount: {
    type: Sequelize.INTEGER,
    defaultValue: 25
  },
  total_amount: Sequelize.INTEGER,
  total_weight: Sequelize.INTEGER
});

Order.hasMany(Product, { as: "ProductList" });

const orderSchema = Joi.object().keys({
  product_list: Joi.array()
    .items(Joi.number())
    .required()
github AvenCloud / aven-legacy / src / DB.js View on Github external
model: model.record,
        key: "id",
      },
    },
    secret: {
      // checksum
      allowNull: false,
      type: Sequelize.STRING,
    },
    expiryTime: {
      allowNull: false,
      type: Sequelize.TIME,
    },
    permission: {
      allowNull: false,
      type: Sequelize.ENUM("WRITE", "READ", "NONE"),
    },
  });

  return model;
}
github artsmia / lume / data-api / db / models / Obj.js View on Github external
type: Sequelize.UUID,
      defaultValue: Sequelize.UUIDV4,
      primaryKey: true
    },
    localId: {
      type: Sequelize.STRING,
      allowNull: false,
      defaultValue: ''
    },
    title: {
      type: Sequelize.STRING,
      allowNull: false,
      defaultValue: ''
    },
    primaryMediaType: {
      type: Sequelize.ENUM('image', 'video'),
      defaultValue: 'image'
    },
    attribution: {
      type: Sequelize.STRING,
      allowNull: false,
      defaultValue: ''
    },
    date: {
      type: Sequelize.STRING,
      allowNull: false,
      defaultValue: ''
    },
    culture: {
      type: Sequelize.STRING,
      allowNull: false,
      defaultValue: ''
github CleverStack / clever-orm / module.js View on Github external
}
      break;
    case Boolean:
      field = Sequelize.BOOLEAN;
      break;
    case Date:
      field = Sequelize.DATE;
      break;
    case Array:
      field = options.of ? Sequelize.ARRAY(this.getFieldType(Static, { type: options.of })) : Sequelize.ARRAY(Sequelize.STRING);
      break;
    case Buffer:
      field = Sequelize.STRING.BINARY;
      break;
    case Model.Types.ENUM:
      field = Sequelize.ENUM(options.values);
      break;
    case Model.Types.TINYINT:
      field = this.tinyIntType(options);
      break;
    case Model.Types.BIGINT:
      field = this.bigIntType(options);
      break;
    case Model.Types.FLOAT:
      field = this.floatType(options);
      break;
    case Model.Types.DECIMAL:
      field = this.decimalType(options);
      break;
    case Model.Types.TEXT:
      field = Sequelize.TEXT;
      break;
github CodehuddleFSA / codehuddle / db / models / interviewProblem.js View on Github external
const InterviewProblem = db.define('interviewProblems', {
  interviewerRating: {
    type: Sequelize.INTEGER,
    validate: {
      min: 0,
      max: 5
    }
  },
  candidateRating: {
    type: Sequelize.INTEGER,
    validate: {
      min: 0,
      max: 5
    }
  },
  status: Sequelize.ENUM('planned', 'used', 'not used', 'reviewed')
});

module.exports = InterviewProblem;
github OriginProtocol / origin / dapps / shop / backend / data / db.js View on Github external
)

const Discounts = sequelize.define(
  'discounts',
  {
    network_id: {
      type: Sequelize.INTEGER
    },
    status: {
      type: Sequelize.ENUM('active', 'inactive')
    },
    code: {
      type: Sequelize.STRING
    },
    discountType: {
      type: Sequelize.ENUM('fixed', 'percentage')
    },
    value: {
      type: Sequelize.INTEGER
    },
    maxUses: {
      type: Sequelize.INTEGER
    },
    onePerCustomer: {
      type: Sequelize.BOOLEAN
    },
    startTime: {
      type: Sequelize.DATE
    },
    endTime: {
      type: Sequelize.DATE
    },
github GarrettLevine / drag-race-api / lib / models / Challenge.js View on Github external
const Sequelize = require('sequelize');
const db = require('./db')

const { Episode } = require('./');

const Challenge = db.define('Challenge', {
  id: {
    type: Sequelize.INTEGER,
    allowNull: false,
    autoIncrement: true,
    primaryKey: true,
  },
  type: {
    type: Sequelize.ENUM('mini', 'main'),
    allowNull: false,
  },
  description: {
    type: Sequelize.STRING,
    allowNull: false,
  },
  prize: {
    type: Sequelize.STRING,
    allowNull: true,
  },
  episodeId: {
    type: Sequelize.INTEGER,
    reference: {
      model: Episode,
      key: 'id',
    },

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