How to use the sequelize.UUID 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 rse / graphql-tools-sequelize / sample / sample.js View on Github external
let db = new Sequelize("./sample.db", "", "", {
        dialect: "sqlite", host: "", port: "", storage: "./sample.db",
        define: { freezeTableName: true, timestamps: false },
        logging: (msg) => { console.log("Sequelize: " + msg) },
    })
    await db.authenticate()

    /*  define database schema  */
    let dm = {}
    dm.OrgUnit = db.define("OrgUnit", {
        id:         { type: Sequelize.UUID,        primaryKey: true  },
        initials:   { type: Sequelize.STRING(3),   allowNull:  false },
        name:       { type: Sequelize.STRING(100), allowNull:  false }
    })
    dm.Person = db.define("Person", {
        id:         { type: Sequelize.UUID,        primaryKey: true  },
        initials:   { type: Sequelize.STRING(3),   allowNull:  false },
        name:       { type: Sequelize.STRING(100), allowNull:  false }
    })
    dm.OrgUnit.belongsTo(dm.OrgUnit, {
        as:         "parentUnit",
        foreignKey: "parentUnitId"
    })
    dm.Person.belongsTo(dm.Person, {
        as:         "supervisor",
        foreignKey: "personId"
    })
    dm.Person.belongsTo(dm.OrgUnit, {
        as:         "belongsTo",
        foreignKey: "orgUnitId"
    })
    dm.OrgUnit.hasMany(dm.Person, {
github nielsgl / sequelize-paper-trail / lib / index.js View on Github external
}

			attributes[options.defaultAttributes.documentId] = {
				type: Sequelize.INTEGER,
				allowNull: false,
			};

			attributes[options.revisionAttribute] = {
				type: Sequelize.INTEGER,
				allowNull: false,
			};

			if (options.UUID) {
				attributes.id = {
					primaryKey: true,
					type: Sequelize.UUID,
					defaultValue: Sequelize.UUIDV4,
				};
				attributes[options.defaultAttributes.documentId].type =
					Sequelize.UUID;
			}

			if (options.debug) {
				log('attributes', attributes);
			}

			// Revision model
			const Revision = sequelize.define(
				options.revisionModel,
				attributes,
				{
					underscored: options.underscored,
github staeco / iris-ql / test / fixtures / db.js View on Github external
import types from 'sequelize'
import { connect } from '../../src'

const db = connect(process.env.POSTGRES_URL || `postgres://postgres@localhost:${process.env.PGPORT || 5432}/iris-ql`)

db.define('user', {
  id: {
    type: types.UUID,
    defaultValue: types.UUIDV4,
    primaryKey: true,
    allowNull: false,
    name: 'ID',
    notes: 'Unique ID',
    validate: {
      notNull: {
        msg: 'This field is required'
      },
      isUUID: {
        args: 4,
        msg: 'Must be a valid UUID'
      }
    }
  },
  createdAt: {
github staeco / iris-ql / test / fixtures / db.js View on Github external
allowNull: true,
    name: 'Location',
    notes: 'Location of the store'
  }
}, {
  timestamps: true,
  scopes: {
    public: {
      attributes: [ 'id', 'createdAt', 'name', 'type', 'location' ]
    }
  }
})

db.define('datum', {
  id: {
    type: types.UUID,
    defaultValue: types.UUIDV4,
    primaryKey: true,
    allowNull: false,
    name: 'ID',
    notes: 'Unique ID',
    validate: {
      notNull: {
        msg: 'This field is required'
      },
      isUUID: {
        args: 4,
        msg: 'Must be a valid UUID'
      }
    }
  },
  createdAt: {
github iverenshaguy / book-a-meal / server / src / models / Notification.js View on Github external
export default (sequelize) => {
  const Notification = sequelize.define(
    'Notification',
    {
      notifId: {
        type: Sequelize.UUID,
        primaryKey: true,
        defaultValue: Sequelize.UUIDV4,
        allowNull: false
      },
      message: {
        type: Sequelize.TEXT,
        allowNull: false
      },
    },
  );

  Notification.associate = (models) => {
    Notification.hasOne(models.User, {
      foreignKey: 'userId',
      onDelete: 'CASCADE',
    });
github artsmia / lume / data-api / db / models / Organization.js View on Github external
import Sequelize from 'sequelize'
import db from '../connect'

const Organization = db.define(
  'organization',
  {
    id: {
      type: Sequelize.UUID,
      defaultValue: Sequelize.UUIDV4,
      primaryKey: true
    },
    name: Sequelize.STRING,
    subdomain: {
      type: Sequelize.STRING,
      unique: true,
      primaryKey: true
    },
    emailDomain: {
      type: Sequelize.STRING,
      allowNull: false,
      defaultValue: ''
    },
    newUsersRequireApproval: {
      type: Sequelize.BOOLEAN,
github quanglam2807 / webcatalog / src / models / app.js View on Github external
import Sequelize from 'sequelize';

import sequelize from '../sequelize';

const App = sequelize.define('app', {
  id: {
    primaryKey: true,
    type: Sequelize.UUID,
    defaultValue: Sequelize.UUIDV4,
  },
  slug: {
    type: Sequelize.STRING,
  },
  name: {
    type: Sequelize.STRING,
  },
  url: {
    type: Sequelize.STRING,
  },
  category: {
    type: Sequelize.STRING,
  },
  isActive: {
    type: Sequelize.BOOLEAN,
github iverenshaguy / book-a-meal / server / src / models / Order.js View on Github external
export default (sequelize) => {
  const Order = sequelize.define(
    'Order',
    {
      orderId: {
        type: Sequelize.UUID,
        primaryKey: true,
        defaultValue: Sequelize.UUIDV4,
        allowNull: false
      },
      deliveryAddress: {
        type: Sequelize.TEXT,
        allowNull: true
      },
      deliveryPhoneNo: {
        type: Sequelize.STRING,
        allowNull: true
      },
      status: {
        type: Sequelize.ENUM('started', 'pending', 'delivered', 'canceled'),
        allowNull: true,
        defaultValue: 'started'
github artsmia / lume / data-api / db / models / Media.js View on Github external
import Sequelize from 'sequelize'
import db from '../connect'

const Media = db.define(
  'media',
  {
    id: {
      type: Sequelize.UUID,
      defaultValue: Sequelize.UUIDV4,
      primaryKey: true
    },
    title: {
      type: Sequelize.STRING,
      allowNull: false,
      defaultValue: ''
    },
    description: {
      type: Sequelize.TEXT,
      allowNull: false,
      defaultValue: ''
    },
    localId: {
      type: Sequelize.STRING,
      allowNull: false,
github electrode-io / electrode-ota-server / electrode-ota-server-dao-mariadb / src / models / Package.js View on Github external
export default sequelize => {
  const PackageDiff = sequelize.import("./PackageDiff");
  const Package = sequelize.define(
    "Package",
    {
      id_: {
        type: Sequelize.UUID,
        defaultValue: Sequelize.UUIDV1,
        primaryKey: true
      },
      appVersion: Sequelize.STRING,
      blobUrl: Sequelize.STRING(2048),
      description: Sequelize.STRING(2048),
      isDisabled: {
        type: Sequelize.BOOLEAN,
        defaultValue: false
      },
      isMandatory: {
        type: Sequelize.BOOLEAN,
        defaultValue: false
      },
      label: Sequelize.STRING,
      manifestBlobUrl: Sequelize.STRING(2048),

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