{"action":"closed","issue":{"url":"https://api.github.com/repos/westmark/sequelize-multi-tenant-enhancer/issues/2","repository_url":"https://api.github.com/repos/westmark/sequelize-multi-tenant-enhancer","labels_url":"https://api.github.com/repos/westmark/sequelize-multi-tenant-enhancer/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/westmark/sequelize-multi-tenant-enhancer/issues/2/comments","events_url":"https://api.github.com/repos/westmark/sequelize-multi-tenant-enhancer/issues/2/events","html_url":"https://github.com/westmark/sequelize-multi-tenant-enhancer/issues/2","id":329254152,"node_id":"MDU6SXNzdWUzMjkyNTQxNTI=","number":2,"title":"Multiple Schemas not working","user":{"login":"sameercodes","id":24786759,"node_id":"MDQ6VXNlcjI0Nzg2NzU5","avatar_url":"https://avatars3.githubusercontent.com/u/24786759?v=4","gravatar_id":"","url":"https://api.github.com/users/sameercodes","html_url":"https://github.com/sameercodes","followers_url":"https://api.github.com/users/sameercodes/followers","following_url":"https://api.github.com/users/sameercodes/following{/other_user}","gists_url":"https://api.github.com/users/sameercodes/gists{/gist_id}","starred_url":"https://api.github.com/users/sameercodes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sameercodes/subscriptions","organizations_url":"https://api.github.com/users/sameercodes/orgs","repos_url":"https://api.github.com/users/sameercodes/repos","events_url":"https://api.github.com/users/sameercodes/events{/privacy}","received_events_url":"https://api.github.com/users/sameercodes/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-06-04T23:47:07Z","updated_at":"2018-06-06T06:08:09Z","closed_at":"2018-06-06T06:08:08Z","author_association":"NONE","body":"This is my api code:\r\n\r\n```javascript\r\nconst Sequelize = require('sequelize');\r\nconst enhance = require('sequelize-multi-tenant-enhancer');\r\nconst Inventory = require('./models/inventory');\r\n\r\nconst db = new Sequelize('postgres://localhost:5432/test');\r\n\r\ndb.authenticate().then((err) => {\r\n  if (err) {\r\n    console.log('There is connection in ERROR.');\r\n  } else {\r\n    console.log('Postgres Connection has been established successfully');\r\n  }\r\n});\r\ndb.sync().then(() => {\r\n  console.log('Missing Table Created');\r\n}, (err) => {\r\n  console.log('An error occurred while creating the table:', err.message);\r\n});\r\n\r\ndb.define('inventory', Inventory);\r\n\r\nconst enhancedSeq = enhance(db);\r\n\r\n// const clientA = enhancedSeq.withSchema('client-a');\r\nconst clientB = enhancedSeq.withSchema('client-b');\r\n\r\n\r\n// apis\r\nexports.getAllBusiness = (req, res) => {\r\n  clientB.models.inventory.findAll()\r\n    .then((results) => {\r\n      res.send(results);\r\n    });\r\n};\r\n\r\nexports.postBusiness = (req, res) => {\r\n  const user = {\r\n    name: 'sameer',\r\n  };\r\n  clientB.models.inventory.create(user)\r\n    .then(data => res.status(200).send(data))\r\n    .catch(Sequelize.ValidationError, err => res.status(422).send(err.errors[0].message))\r\n    .catch(err => res.status(400).send(err.message));\r\n};\r\n\r\n```\r\n\r\nMy inventory model:\r\n```javascript\r\nconst Sequelize = require('sequelize');\r\n\r\nmodule.exports = {\r\n  name: Sequelize.STRING,\r\n  code: Sequelize.STRING,\r\n  price: Sequelize.STRING,\r\n};\r\n\r\n```\r\n\r\nI am using postgres as a database, Initially the tables are successfully created, after creation i am hitting my post api with clientA schema so now data successfully stored in my db, but if i change my findAll code with clientB, still the data shows up!\r\n\r\n\r\n"}}
{"actor":{"display_login":"sameercodes"}}