Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const Sequelize = require('sequelize');
var db = require('../../_db');
const bcrypt = require('bcrypt');
const Play = db.define('plays', {
title: {
type: Sequelize.STRING,
allowNull: false
},
playJson: {
type: Sequelize.JSON,
allowNull: false
},
hashedPlay: {
type: Sequelize.STRING
},
image: {
type: Sequelize.TEXT
}
}, {
hooks: {
beforeValidate: setHashedPlay,
beforeUpdate: setHashedPlay
}
});
// hash the play data to use as secure parameter in get one route for sharing model
export interface SettingAttributes extends BaseAttributes {
id: number;
guildId: string;
value: SettingsObject;
}
export interface SettingInstance extends Sequelize.Instance, SettingAttributes {
getGuild: Sequelize.BelongsToGetAssociationMixin;
}
export const settings = sequelize.define(
'setting',
{
id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true },
guildId: Sequelize.STRING(32),
value: Sequelize.JSON
},
{
timestamps: true,
paranoid: true,
indexes: [
{
unique: true,
fields: ['guildId']
}
]
}
);
settings.belongsTo(guilds);
guilds.hasMany(settings);
// ------------------------------------
string_id: {
type: Sequelize.STRING,
allowNull: true,
// allowNull: false,
unique: true,
},
title: {
type: Sequelize.STRING,
allowNull: false,
},
body: {
type: Sequelize.TEXT,
allowNull: false,
},
assets: {
type: Sequelize.JSON,
allowNull: true,
},
}, {
sequelize,
hooks: {
// TODO: {blog post} beforeValidate instead of beforeCreate, because beforeValidate runs before beforeCreate.
beforeValidate: (post) => {
post.string_id = post.title.replace(/\s+/g, '-').toLowerCase();
},
},
});
}
export default (sequelize: Sequelize.Sequelize): typeof EntrypointModel => {
EntrypointModel.init(
{
id: { type: Sequelize.STRING, primaryKey: true },
appId: { type: Sequelize.STRING },
bundleId: { type: Sequelize.STRING },
redirectTo: { type: Sequelize.STRING },
urlMatcher: { type: Sequelize.STRING },
configuration: { type: Sequelize.JSON },
createdAt: { type: Sequelize.DATE },
updatedAt: { type: Sequelize.DATE }
},
{
sequelize: sequelize,
tableName: ENTRYPOINTS_TABLE
}
);
return EntrypointModel;
};
} catch (e) {
console.error('Create your own secrets file lazybones');
secret = require('../secret-sample.json')
}
const DATABASE_URL = process.env.DATABASE_URL || ('postgres://' + secret.DB_USER + ":" + secret.DB_PASSWORD + "@" + secret.DB_HOST + ":5432/" + secret.DATABASE);
const db = new Sequelize(DATABASE_URL, {
dialect: 'postgres'
});
const Student = db.define('student', {
id: {type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true},
education: Sequelize.ARRAY(Sequelize.JSON),
skills: Sequelize.ARRAY(Sequelize.JSON),
compLanguages: Sequelize.ARRAY(Sequelize.JSON),
projects: Sequelize.ARRAY(Sequelize.JSON),
trainings: Sequelize.ARRAY(Sequelize.JSON),
cbStudent: {type: Sequelize.BOOLEAN, defaultValue: false},
cbCourses: Sequelize.ARRAY(Sequelize.STRING),
});
const CompanyManager = db.define('companymanager', {
id: {type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true},
designation: Sequelize.STRING,
});
const Admin = db.define('admin', {
id: {type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true},
}, {
name: 'channelId_idx',
fields: ['channelId']
}, {
name: 'createdAt_idx',
fields: ['createdAt']
}]
});
ChatIdChannelId.belongsTo(Chat, {foreignKey: 'chatId', targetKey: 'id', onUpdate: 'CASCADE', onDelete: 'CASCADE'});
ChatIdChannelId.belongsTo(Channel, {foreignKey: 'channelId', targetKey: 'id', onUpdate: 'CASCADE', onDelete: 'CASCADE'});
const Video = this.sequelize.define('video', {
id: {type: Sequelize.STRING(191), allowNull: false, primaryKey: true},
url: {type: Sequelize.STRING(191), allowNull: false},
title: {type: Sequelize.STRING(191), allowNull: false},
previews: {type: Sequelize.JSON, allowNull: false},
duration: {type: Sequelize.STRING(191), allowNull: true},
channelId: {type: Sequelize.STRING(191), allowNull: false},
publishedAt: {type: Sequelize.DATE, allowNull: false},
telegramPreviewFileId: {type: Sequelize.TEXT, allowNull: true},
mergedId: {type: Sequelize.STRING(191), allowNull: true},
mergedChannelId: {type: Sequelize.STRING(191), allowNull: true},
}, {
tableName: 'videos',
timestamps: true,
updatedAt: false,
indexes: [{
name: 'publishedAt_idx',
fields: ['publishedAt']
}]
});
Video.belongsTo(Channel, {foreignKey: 'channelId', targetKey: 'id', onUpdate: 'CASCADE', onDelete: 'CASCADE'});
uniqueKeys: {
rounds_unique: {
fields: ['publicKey', 'round']
}
},
indexes: [{
fields: ['publicKey']
}, {
fields: ['round']
}]
})
const webhooks = db.define('webhooks', {
event: Sequelize.STRING,
target: Sequelize.STRING,
conditions: Sequelize.JSON,
secret: Sequelize.STRING,
enabled: Sequelize.BOOLEAN
}, {
indexes: [{
fields: ['event']
}]
})
return Promise.all([blocks, transactions, wallets, rounds, webhooks].map(table => table.sync()))
}
'use strict'
const Sequelize = require('sequelize')
const db = require('APP/db')
const Recording = db.define('recordings', {
text: {
type: Sequelize.TEXT,
allowNull: false,
},
personality: Sequelize.JSON,
tone: Sequelize.JSON,
created_at: Sequelize.DATE
});
module.exports = Recording;
allowNull: false
},
tag: {
type: Sequelize.STRING,
allowNull: false
},
description: {
type: Sequelize.TEXT,
allowNull: false
},
hash: {
type: Sequelize.STRING,
allowNull: false
},
assets: {
type: Sequelize.JSON,
allowNull: false
},
createdAt: {
type: Sequelize.DATE,
allowNull: false
}
});
await q.createTable(APPS_TABLE, {
id: {
type: Sequelize.STRING,
primaryKey: true
},
name: {
type: Sequelize.STRING,
unique: true,
name: 'Boolean',
graphQLInputType: GraphQLBoolean,
graphQLOutputType: GraphQLBoolean,
columnType: Sequelize.BOOLEAN
}),
Date: new ScalarFieldType({
name: 'Date',
graphQLInputType: GraphQLScalarTypes.Date,
graphQLOutputType: GraphQLScalarTypes.Date,
columnType: Sequelize.DATE
}),
JSON: new ScalarFieldType({
name: 'JSON',
graphQLInputType: GraphQLScalarTypes.Json,
graphQLOutputType: GraphQLScalarTypes.Json,
columnType: Sequelize.JSON
})
} : {[id:string]:ScalarFieldType})
}