SHARE
TWEET

Untitled

a guest Oct 3rd, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Sequelize = require('sequelize');
  2. const sequelize = require('../config');
  3. let Users = sequelize.define('users', {
  4.   id : {
  5.     type: Sequelize.INTEGER,
  6.     primaryKey: true,
  7.     autoIncrement: true
  8.   },
  9.   username: {
  10.     type: Sequelize.STRING,
  11.   },
  12.   password: {
  13.     type: Sequelize.STRING
  14.   }
  15. });
  16. module.exports = Users;
  17.    
  18. const Sequelize = require('sequelize');
  19. const sequelize = require('../config');
  20. let products=sequelize.define('products', {
  21.   id : {
  22.     type: Sequelize.INTEGER,
  23.     primaryKey: true,
  24.     autoIncrement: true
  25.   },
  26.   category : {
  27.     type: Sequelize.STRING,
  28.     allowNull: false
  29.   },
  30.   name : {
  31.     type: Sequelize.STRING,
  32.     allowNull: false
  33.   },
  34.   price: {
  35.     type: Sequelize.INTEGER,
  36.     allowNull: false
  37.   }
  38. });
  39. module.exports= products;
  40.    
  41. const Sequelize = require('sequelize');
  42. const sequelize = require('../config');
  43. let users=require('./user');
  44. let products=require('./product');
  45. let orders=sequelize.define('orders', {
  46.   id: {
  47.     type: Sequelize.INTEGER,
  48.     primaryKey: true,
  49.     autoIncrement: true
  50.   },
  51.   user_id: {
  52.     type: Sequelize.INTEGER,
  53.     references: {
  54.         model: 'users',
  55.         key: 'id'
  56.     }
  57.   },
  58.   product_id: {
  59.     type: Sequelize.INTEGER,
  60.     references: {
  61.         model: 'products',
  62.         key: 'id'
  63.     }
  64.   },
  65.   price: {
  66.     type: Sequelize.INTEGER,
  67.     allowNull: false
  68.   }
  69. });
  70. module.exports= orders;
  71.    
  72. SELECT * FROM ((orders INNER JOIN users ON users.id=orders.user_id) INNER JOIN products ON products.id=orders.product_id);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top