Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(/** @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'
}
};
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: {
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,
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, {
} 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) {
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> {
@Unique
@Default(Sequelize.UUIDV4)
@Column({
type: Sequelize.UUID,
field: 'identity'
})
identity: string;
}
</i>
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: {
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
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
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