Created
July 19, 2016 13:50
-
-
Save ruprict/51d83f3883c4075801a61bc50b30a271 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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