Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Instead, a unique ID is created on the client and stored in localStorage.
// There is no authorization process; I use this model purely to group art
// together, so that I can easily find all pieces created by a specific user
// ID.
export const User = sequelize.define('user', {
id: { type: Sequelize.UUID, primaryKey: true },
name: { type: Sequelize.STRING, allowNull: true },
email: Sequelize.STRING,
});
export const Order = sequelize.define('order', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
},
format: Sequelize.ENUM('print', 'vector', 'combo'),
size: Sequelize.ENUM('small', 'medium', 'large'),
cost: Sequelize.INTEGER,
artParams: Sequelize.JSON,
chargeId: Sequelize.STRING,
shipped: { type: Sequelize.BOOLEAN, allowNull: true },
// Shipping address
shipTo: Sequelize.STRING,
streetAddress: Sequelize.STRING,
city: Sequelize.STRING,
state: Sequelize.STRING,
country: Sequelize.STRING,
zipCode: Sequelize.STRING,
// Image URLs
svgUrl: { type: Sequelize.STRING, allowNull: true },
pngUrlOpaque: { type: Sequelize.STRING, allowNull: true },
pngUrlTransparent: { type: Sequelize.STRING, allowNull: true },
type: Sequelize.TEXT
}
},
{
// options
}
)
const Discounts = sequelize.define(
'discounts',
{
network_id: {
type: Sequelize.INTEGER
},
status: {
type: Sequelize.ENUM('active', 'inactive')
},
code: {
type: Sequelize.STRING
},
discountType: {
type: Sequelize.ENUM('fixed', 'percentage')
},
value: {
type: Sequelize.INTEGER
},
maxUses: {
type: Sequelize.INTEGER
},
onePerCustomer: {
type: Sequelize.BOOLEAN
},
// Schemas and models
const Product = sequelize.define("product", {
name: Sequelize.STRING,
price: Sequelize.INTEGER,
weight: Sequelize.INTEGER
});
const productSchema = Joi.object().keys({
name: Joi.required(),
price: Joi.required(),
weight: Joi.required()
});
const Order = sequelize.define("order", {
status: {
type: Sequelize.ENUM("pending", "cancelled", "paid"),
defaultValue: "pending"
},
shipment_amount: {
type: Sequelize.INTEGER,
defaultValue: 25
},
total_amount: Sequelize.INTEGER,
total_weight: Sequelize.INTEGER
});
Order.hasMany(Product, { as: "ProductList" });
const orderSchema = Joi.object().keys({
product_list: Joi.array()
.items(Joi.number())
.required()
model: model.record,
key: "id",
},
},
secret: {
// checksum
allowNull: false,
type: Sequelize.STRING,
},
expiryTime: {
allowNull: false,
type: Sequelize.TIME,
},
permission: {
allowNull: false,
type: Sequelize.ENUM("WRITE", "READ", "NONE"),
},
});
return model;
}
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
primaryKey: true
},
localId: {
type: Sequelize.STRING,
allowNull: false,
defaultValue: ''
},
title: {
type: Sequelize.STRING,
allowNull: false,
defaultValue: ''
},
primaryMediaType: {
type: Sequelize.ENUM('image', 'video'),
defaultValue: 'image'
},
attribution: {
type: Sequelize.STRING,
allowNull: false,
defaultValue: ''
},
date: {
type: Sequelize.STRING,
allowNull: false,
defaultValue: ''
},
culture: {
type: Sequelize.STRING,
allowNull: false,
defaultValue: ''
}
break;
case Boolean:
field = Sequelize.BOOLEAN;
break;
case Date:
field = Sequelize.DATE;
break;
case Array:
field = options.of ? Sequelize.ARRAY(this.getFieldType(Static, { type: options.of })) : Sequelize.ARRAY(Sequelize.STRING);
break;
case Buffer:
field = Sequelize.STRING.BINARY;
break;
case Model.Types.ENUM:
field = Sequelize.ENUM(options.values);
break;
case Model.Types.TINYINT:
field = this.tinyIntType(options);
break;
case Model.Types.BIGINT:
field = this.bigIntType(options);
break;
case Model.Types.FLOAT:
field = this.floatType(options);
break;
case Model.Types.DECIMAL:
field = this.decimalType(options);
break;
case Model.Types.TEXT:
field = Sequelize.TEXT;
break;
const InterviewProblem = db.define('interviewProblems', {
interviewerRating: {
type: Sequelize.INTEGER,
validate: {
min: 0,
max: 5
}
},
candidateRating: {
type: Sequelize.INTEGER,
validate: {
min: 0,
max: 5
}
},
status: Sequelize.ENUM('planned', 'used', 'not used', 'reviewed')
});
module.exports = InterviewProblem;
)
const Discounts = sequelize.define(
'discounts',
{
network_id: {
type: Sequelize.INTEGER
},
status: {
type: Sequelize.ENUM('active', 'inactive')
},
code: {
type: Sequelize.STRING
},
discountType: {
type: Sequelize.ENUM('fixed', 'percentage')
},
value: {
type: Sequelize.INTEGER
},
maxUses: {
type: Sequelize.INTEGER
},
onePerCustomer: {
type: Sequelize.BOOLEAN
},
startTime: {
type: Sequelize.DATE
},
endTime: {
type: Sequelize.DATE
},
const Sequelize = require('sequelize');
const db = require('./db')
const { Episode } = require('./');
const Challenge = db.define('Challenge', {
id: {
type: Sequelize.INTEGER,
allowNull: false,
autoIncrement: true,
primaryKey: true,
},
type: {
type: Sequelize.ENUM('mini', 'main'),
allowNull: false,
},
description: {
type: Sequelize.STRING,
allowNull: false,
},
prize: {
type: Sequelize.STRING,
allowNull: true,
},
episodeId: {
type: Sequelize.INTEGER,
reference: {
model: Episode,
key: 'id',
},