{"action":"opened","issue":{"url":"https://api.github.com/repos/hauru/sequelize-to-json/issues/8","repository_url":"https://api.github.com/repos/hauru/sequelize-to-json","labels_url":"https://api.github.com/repos/hauru/sequelize-to-json/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/hauru/sequelize-to-json/issues/8/comments","events_url":"https://api.github.com/repos/hauru/sequelize-to-json/issues/8/events","html_url":"https://github.com/hauru/sequelize-to-json/issues/8","id":346848725,"node_id":"MDU6SXNzdWUzNDY4NDg3MjU=","number":8,"title":"Error during model instance comparison","user":{"login":"apoorvparijat","id":1388235,"node_id":"MDQ6VXNlcjEzODgyMzU=","avatar_url":"https://avatars2.githubusercontent.com/u/1388235?v=4","gravatar_id":"","url":"https://api.github.com/users/apoorvparijat","html_url":"https://github.com/apoorvparijat","followers_url":"https://api.github.com/users/apoorvparijat/followers","following_url":"https://api.github.com/users/apoorvparijat/following{/other_user}","gists_url":"https://api.github.com/users/apoorvparijat/gists{/gist_id}","starred_url":"https://api.github.com/users/apoorvparijat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apoorvparijat/subscriptions","organizations_url":"https://api.github.com/users/apoorvparijat/orgs","repos_url":"https://api.github.com/users/apoorvparijat/repos","events_url":"https://api.github.com/users/apoorvparijat/events{/privacy}","received_events_url":"https://api.github.com/users/apoorvparijat/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-02T03:47:52Z","updated_at":"2018-08-02T03:47:52Z","closed_at":null,"author_association":"NONE","body":"Hi\r\n\r\nI ran into an error when serializing with two different model class object. Check the code below and take note of \"Object 1\" and \"Object 2\".\r\n\r\n```\r\nexport function getSegmentProfilesFor(tenant, segmentId) {\r\n  // Object 1 of SegmentProfile\r\n  const SegmentProfile = models(authorizerContext.tenant).SegmentProfile;\r\n  const segmentProfiles = SegmentProfile.findAll({\r\n    where: {\r\n      segmentId: segmentId\r\n    },\r\n    order: [['createdAt', 'DESC']]\r\n  })\r\n  return segmentProfiles;\r\n}\r\n\r\n\r\nconst segmentProfiles = await getSegmentProfilesFor(authorizerContext.tenant, segmentId, SegmentProfile);\r\n\r\n// Object 2 of SegmentProfile\r\nconst SegmentProfile = models(authorizerContext.tenant).SegmentProfile; \r\nlet segmentProfilesAsJSON = Serializer.serializeMany(segmentProfiles, SegmentProfile, serializeProfileScheme);\r\n```\r\n\r\nLooks like the below piece of code is comparing for the exact model instance. Even when we pass another instance of the same class, the logic doesn't work.\r\n\r\n```\r\nfunction _isSpecificModelInstance(obj, model, seqVer) {\r\n  if(seqVer >= 4) {\r\n    return obj instanceof model;\r\n  } else {\r\n    return obj instanceof model.Instance;\r\n  }\r\n}\r\n```\r\n[Line 111](https://github.com/hauru/sequelize-to-json/blob/f2e814ca8641fcd543e6f1630bb199c79d25f144/index.js#L111)\r\n\r\nPlease help me understand the need for comparing via `instanceof` instead of model class name."}}
{"actor":{"display_login":"apoorvparijat"}}