Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const CustomerCoupon = sequelize.define('customer_coupon',{
- coupon_id:{
- type:Sequelize.BIGINT,
- allowNull:false
- },
- customer_id:{
- type:Sequelize.BIGINT,
- allowNull:false
- }
- },{
- schema:'couponsystem'
- });
- const Customer = sequelize.define('customer',{
- customer_id:{
- type:Sequelize.BIGINT,
- primaryKey:true,
- allowNull:false
- },
- nickname: {
- type:Sequelize.STRING(100),
- allowNull:false,
- unique:true
- },
- firstname:{
- type:Sequelize.STRING(100),
- allowNull:false
- },
- lastname:{
- type:Sequelize.STRING(100),
- allowNull:false
- },
- email:{
- type:Sequelize.STRING(150),
- unique:true,
- allowNull:false
- },
- password:{
- type:Sequelize.STRING(150),
- unique:true,
- allowNull:false
- },
- country:{
- type:Sequelize.STRING(100),
- allowNull:false
- }
- },{
- schema:'couponsystem',
- underscored:true
- });
- const Coupon = sequelize.define('coupon',{
- coupon_id: {
- primaryKey:true,
- type:Sequelize.BIGINT,
- allowNull:false
- },
- title: {
- unique:true,
- type:Sequelize.STRING(50),
- allowNull:false
- },
- release_date: {
- type:Sequelize.DATE,
- release_time:Sequelize.DATE,
- allowNull:false
- },
- expiration_date:{
- type:Sequelize.DATE,
- allowNull:false
- },
- price: {
- type:Sequelize.DOUBLE,
- allowNull:false
- },
- coupon_type:{
- type:Sequelize.ENUM('Traveling','Food','Camping','Restaurants'),
- allowNull:false
- }
- },{
- schema:'couponsystem'
- });
- const User = sequelize.define('user', {
- user_id: {
- primaryKey:true,
- type:Sequelize.BIGINT,
- allowNull:false
- },
- nickname: {
- type:Sequelize.STRING(150),
- unique:true,
- allowNull:false
- },
- email: {
- type:Sequelize.STRING(150),
- unique:true,
- allowNull:false
- },
- user_password: {
- type:Sequelize.STRING(150),
- unique:true,
- allowNull:false
- }
- }, {
- schema:'couponsystem',
- underscored:true
- });
- // CustomerCoupon.removeAttribute('id');
- Coupon.belongsToMany(Customer, {through: CustomerCoupon});
- Customer.belongsToMany(Coupon, {through: CustomerCoupon});
- User.hasOne(Customer,{foreignKey:'user_id'});
- var Bar = sequelize.define('Bar', { /* bla */ }, {
- // disable the modification of tablenames; By default, sequelize will automatically
- // transform all passed model names (first parameter of define) into plural.
- // if you don't want that, set the following
- freezeTableName: true,
- })
Add Comment
Please, Sign In to add comment