Skip to content

Instantly share code, notes, and snippets.

@ruprict
Created July 19, 2016 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruprict/51d83f3883c4075801a61bc50b30a271 to your computer and use it in GitHub Desktop.
Save ruprict/51d83f3883c4075801a61bc50b30a271 to your computer and use it in GitHub Desktop.
var Sequelize =require('sequelize');
const Conn = new Sequelize(process.env.DATABASE_URL);
// const Conn = new Sequelize(
// 'test',
// 'postgres',
// 'postgres',
// { dialect: 'postgres', host: 'localhost' }
// )
function connection() {
console.log("*** Creating connection")
const Conn = new Sequelize(process.env.DATABASE_URL);
return Conn;
}
module.exports = connection();
var conn =require('./conn');
var Sequelize = require('sequelize');
module.exports = Product = conn.define('product', {
activated_at: {
type: Sequelize.DATE,
allowNull: true
},
//activation_scope
country_of_origin: {
type: Sequelize.STRING,
allowNull: false
},
deactivated_at: {
type: Sequelize.DATE,
allowNull: true
},
// foundation: {
// },
id: {
primaryKey: true,
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
},
// images
// manufacturer: {
// },
name: {
type: Sequelize.STRING,
allowNull: false
},
// options
// pattern: {
// },
// pile: {
// },
product_type: {
type: Sequelize.STRING,
allowNull: false,
validate: {
isIn: {
msg: "Must be one of: rugs, pillows, rug_pads",
args: [['rugs', 'pillows', 'rug_pads']]
}
}
},
// products
// quality: {
// },
status: {
type: Sequelize.STRING,
allowNull: false,
validate: {
isIn: {
msg: "Must be one of: new, activated",
args: [['new', 'activated']]
}
}
},
// styles: {
// },
sub_collection: {
type: Sequelize.STRING,
allowNull: false
},
tags: {
type: Sequelize.ARRAY(Sequelize.STRING),
allowNull: false,
defaultValue: []
},
thickness_cm: {
type: Sequelize.INTEGER,
allowNull: false
},
weave: {
type: Sequelize.STRING,
allowNull: false
}
}, {
paranoid: true,
underscored: true
});
conn.sync({force: true})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment