Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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, {
}
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,
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: {
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: {
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',
});
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,
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,
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'
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,
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),