How to use the sequelize.UUIDV4 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 flowgrammable / flowsim / scratch / jasson / backend / src / subscriber / models / subscriber.js View on Github external
(/** @lends module:subscriber */function(){

var sequelize = require('sequelize');

module.exports = {
  name: 'subscriber',
	table: {
    email: sequelize.STRING,
    password: sequelize.STRING,
    reg_date: sequelize.DATE,
    reg_ip: sequelize.STRING,
    verification_token: sequelize.UUIDV4,
    reset_token: sequelize.UUIDV4,
    status: sequelize.STRING
	},
  relations: {
    // hasMany: { relative: "switch_profile", options: { as: "Profiles" } },
		// hasOne:"session"
		hasMany: { relative: "switch_profile", options: { as: "Profile"}},
		hasMany: { relative: "packet", options: { as: "Packet" }}
	},
	options: {
		timestamps: false,
		underscored: true,
		tableName: 'subscriber'
	}
};
github underlay / underlay-api / sqldb.js View on Github external
const useSSL = process.env.DATABASE_URL.indexOf('localhost:') === -1;
const sequelize = new Sequelize(process.env.DATABASE_URL, {
	logging: false,
	dialectOptions: { ssl: useSSL },
	operatorsAliases: Sequelize.Op,
});

// Change to true to update the model in the database.
// NOTE: This being set to true will erase your data.
sequelize.sync({ force: false });

const id = {
	primaryKey: true,
	type: Sequelize.UUID,
	defaultValue: Sequelize.UUIDV4,
};

const Assertion = sequelize.define('Assertion', {
	id: id,
	assertion: { type: Sequelize.JSONB, allowNull: false },
	nodeId: { type: Sequelize.UUID, allowNull: false },
	nodeType: { type: Sequelize.TEXT, allowNull: false },
});

const User = sequelize.define('User', {
	id: id,
	slug: {
		type: Sequelize.TEXT,
		unique: true,
		allowNull: false,
		validate: {
github artsmia / lume / data-api / db / models / User_Organization.js View on Github external
import Sequelize from 'sequelize'
import db from '../connect'

const User_Organization = db.define(
  'user_organization',
  {
    id: {
      type: Sequelize.UUID,
      defaultValue: Sequelize.UUIDV4,
      primaryKey: true
    },
    userId: {
      type: Sequelize.STRING
    },
    // organizationId:{
    //     type: Sequelize.UUID,
    //     references: {
    //       model: 'organization',
    //       key: 'id'
    //     },
    //     onDelete: 'CASCADE',
    //     onUpdate: 'CASCADE'
    //   },
    role: {
      type: Sequelize.ENUM,
github interledger-deprecated / ilp-kit / api / src / models / settlement.js View on Github external
data = _.omit(data, _.isNull)
      return data
    }

    static convertToPersistent (data) {
      return data
    }
  }

  Settlement.validateExternal = validator.create('Settlement')

  PersistentModelMixin(Settlement, sequelize, {
    id: {
      type: Sequelize.UUID,
      primaryKey: true,
      defaultValue: Sequelize.UUIDV4
    },
    amount: Sequelize.INTEGER,
    currency: Sequelize.STRING
  })

  deps.later(() => {
    const Peer = deps(PeerFactory)
    const User = deps(UserFactory)
    const SettlementMethod = deps(SettlementMethodFactory)
    const ActivityLog = deps(ActivityLogFactory)
    const ActivityLogsItem = deps(ActivityLogsItemFactory)

    Settlement.DbModel.belongsTo(Peer.DbModel)
    Settlement.DbModel.belongsTo(User.DbModel)
    Settlement.DbModel.belongsTo(SettlementMethod.DbModel)
    Settlement.DbModel.belongsToMany(ActivityLog.DbModel, {
github boscoh / jolecule / vueapp / nodeserver / src / dbmodel.js View on Github external
} else {
          resolve(null)
        }
      })
  })
}

/**
 * Custom database models and relationships between models
 */

const Object = db.define('Object', {
  id: {
    primaryKey: true,
    type: Sequelize.UUID,
    defaultValue: Sequelize.UUIDV4
  },
  attr: sequelizeJson(db, 'Object', 'attr'),
  type: Sequelize.STRING,
  data: Sequelize.BLOB
})

async function createObject (attr, data) {
  let object = await Object.create({attr, data})
  return unwrapInstance(object)
}

function findObject (objectId) {
  return Object.findOne({where: {id: objectId}})
}

function fetchObject (objectId) {
github TeamHive / nestjs-seed / src / app / modules / common / entities / base.entity.ts View on Github external
import * as Sequelize from 'sequelize';
import { Table, Column, Model, Unique, Default } from 'sequelize-typescript';

@Table({
    paranoid: true,
    timestamps: true,
    underscored: true,
    freezeTableName: true
})
export class BaseEntity<i> extends Model&gt; {
    @Unique
    @Default(Sequelize.UUIDV4)
    @Column({
        type: Sequelize.UUID,
        field: 'identity'
    })
    identity: string;
}
</i>
github iverenshaguy / book-a-meal / server / src / models / Meal.js View on Github external
export default (sequelize) => {
  const Meal = sequelize.define(
    'Meal',
    {
      mealId: {
        type: Sequelize.UUID,
        primaryKey: true,
        defaultValue: Sequelize.UUIDV4,
        allowNull: false
      },
      title: {
        type: Sequelize.STRING,
        allowNull: false
      },
      imageUrl: {
        type: Sequelize.TEXT,
        allowNull: false,
        defaultValue: 'https://res.cloudinary.com/iverenshaguy/image/upload/v1532540264/bookameal/default-img.jpg'
      },
      description: {
        type: Sequelize.TEXT,
        allowNull: true
      },
      vegetarian: {
github oughtinc / mosaic / server / lib / models / workspaceVersion.js View on Github external
module.exports = (sequelize, DataTypes) => {
  var WorkspaceVersion = sequelize.define('WorkspaceVersion', {
    id: {
      type: DataTypes.UUID(),
      primaryKey: true,
      defaultValue: Sequelize.UUIDV4,
      allowNull: false,
    },
    childWorkspaceOrder: {
      type: DataTypes.ARRAY(DataTypes.TEXT),
      defaultValue: []
    },
    //This field represents cached data. You can find it from the relevant timestamps.
    childWorkspaceVersionIds: {
      type: DataTypes.JSON,
      defaultValue: {}
    },
    //This field represents cached data. You can find it from checking if its in the childWorkspaceOrder of its parent.
    isArchived: {
      type: DataTypes.BOOLEAN(),
      defaultValue: false,
      allowNull: false
github artsmia / lume / server / src / db / models / video.js View on Github external
import Sequelize from 'sequelize'
import db from '../connect'

const Video = db.define('video', {
  id: {
    type: Sequelize.UUID,
    defaultValue: Sequelize.UUIDV4,
    primaryKey: true
  },
  title: {
    type: Sequelize.STRING,
  },
  url: {
    type: Sequelize.STRING,
  },
}, {
  freezeTableName: true
})


export default Video
github artsmia / lume / server / src / db / models / comparison.js View on Github external
import Sequelize from 'sequelize'
import db from '../connect'

const Comparison = db.define('comparison', {
  id: {
    type: Sequelize.UUID,
    defaultValue: Sequelize.UUIDV4,
    primaryKey: true
  },
  title: {
    type: Sequelize.STRING,
  },
  description: {
    type: Sequelize.STRING,
  },
}, {
  freezeTableName: true
})


export default Comparison

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