{"action":"created","issue":{"url":"https://api.github.com/repos/overlookmotel/sequelize-hierarchy/issues/71","repository_url":"https://api.github.com/repos/overlookmotel/sequelize-hierarchy","labels_url":"https://api.github.com/repos/overlookmotel/sequelize-hierarchy/issues/71/labels{/name}","comments_url":"https://api.github.com/repos/overlookmotel/sequelize-hierarchy/issues/71/comments","events_url":"https://api.github.com/repos/overlookmotel/sequelize-hierarchy/issues/71/events","html_url":"https://github.com/overlookmotel/sequelize-hierarchy/issues/71","id":167958627,"number":71,"title":"it's only returns first child or first parent, ","user":{"login":"kzimic","id":3506362,"avatar_url":"https://avatars.githubusercontent.com/u/3506362?v=3","gravatar_id":"","url":"https://api.github.com/users/kzimic","html_url":"https://github.com/kzimic","followers_url":"https://api.github.com/users/kzimic/followers","following_url":"https://api.github.com/users/kzimic/following{/other_user}","gists_url":"https://api.github.com/users/kzimic/gists{/gist_id}","starred_url":"https://api.github.com/users/kzimic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kzimic/subscriptions","organizations_url":"https://api.github.com/users/kzimic/orgs","repos_url":"https://api.github.com/users/kzimic/repos","events_url":"https://api.github.com/users/kzimic/events{/privacy}","received_events_url":"https://api.github.com/users/kzimic/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/overlookmotel/sequelize-hierarchy/labels/help%20wanted","name":"help wanted","color":"159818"},{"url":"https://api.github.com/repos/overlookmotel/sequelize-hierarchy/labels/possible%20bug","name":"possible bug","color":"e99695"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2016-07-27T21:15:59Z","updated_at":"2016-08-10T17:03:23Z","closed_at":null,"body":"Hello there,\r\n\r\nThank you for the plugin, however I'm only getting the first parent or just the first child when using this plugin. Per your documentation below service should give me the results for hierarchyLevel 6 to hierarchyLevel 1, but it only gives me hierarchyLevel 6 and hierarchyLevel 5:\r\n\r\n\r\n```js\r\n//route\r\n\trouter.get('/', function (req, res, next) {\r\n\t    models.Category.findAll({\r\n\t\t\r\n\t\t\twhere: { id: 3368 },\r\n\t\t\tattributes: ['id','parentId'],\r\n\t\t\thierarchy: true,\r\n\t    \tinclude: [\r\n\t\t\t\t{ \r\n\t\t\t\t\tmodel: models.Category, \r\n\t\t\t\t\tattributes: ['id','parentId','hierarchyLevel'],\r\n\t\t\t\t\tas: 'ancestors'\r\n\t\t\t\t}        \r\n\t\t\t],\r\n\r\n\t    \torder: [ \r\n\t\t\t\t[ \r\n\t\t\t\t\t{ model: models.Category, as: 'ancestors'}, \r\n\t\t\t\t\t'hierarchyLevel' \r\n\t\t\t\t] \r\n\t\t\t]\r\n\r\n\r\n\t\t}).then(function(result) {\r\n\t\t\tres.send(result);\r\n\t\t\tres.end();\r\n\t\t});\r\n\t});\r\n\r\n//category model\r\n\r\nmodule.exports = function (sequelize, DataTypes) {\r\n    var Category = sequelize.define('Category', {\r\n        id: {\r\n            type: DataTypes.INTEGER(11),\r\n            allowNull: false,\r\n            autoIncrement: true,\r\n        },\r\n\t\tasset_id: {\r\n            type: DataTypes.INTEGER(11),\r\n            allowNull: false,\r\n\t\t},\r\n        parentId: {\r\n            type: DataTypes.INTEGER(11),\r\n            allowNull: false,\r\n        },\r\n        hierarchyLevel: {\r\n            type: DataTypes.INTEGER(11),\r\n            allowNull: false,\r\n        },\r\n\t\tpath: {\r\n            type: DataTypes.STRING,\r\n            allowNull: false,\r\n\t\t},\r\n\t\ttitle: {\r\n            type: DataTypes.STRING,\r\n            allowNull: false,\r\n\t\t},\r\n\t\talias: {\r\n            type: DataTypes.STRING,\r\n            allowNull: false,\r\n\t\t},\r\n\t\tdescription: {\r\n            type: DataTypes.TEXT,\r\n            allowNull: true,\r\n\t\t},\r\n\t\tpublished: {\r\n            type: DataTypes.INTEGER(1),\r\n            allowNull: false,\r\n\t\t},\r\n\t\tpid: {\r\n            type: DataTypes.INTEGER(11),\r\n            allowNull: false,\r\n        },\r\n\t\tpmshow: {\r\n            type: DataTypes.INTEGER(1),\r\n            allowNull: false,\r\n\t\t}\r\n    }, {\r\n        tableName: 'category',\r\n        freezeTableName: true,\r\n        timestamps: false\r\n    });\r\n    return Category;\r\n};\r\n\r\n//category ancestor model\r\n\r\nmodule.exports = function (sequelize, DataTypes) {\r\n    var CategoryAncestor = sequelize.define('CategoryAncestor', {\r\n        categoryId: {\r\n            type: DataTypes.INTEGER(11),\r\n            allowNull: false,\r\n        },\r\n        ancestorId: {\r\n            type: DataTypes.INTEGER(11),\r\n            allowNull: false,\r\n        }\r\n    }, {\r\n        tableName: 'category_to_ancestor',\r\n        freezeTableName: true,\r\n        timestamps: false\r\n    });\r\n    return CategoryAncestor;\r\n};\r\n\r\n// associations\r\n\r\nm.Category.belongsTo(m.Category, {as: 'parent', foreignKey: 'parentId'});\r\nm.Category.hasMany(m.Category, {as: 'children', foreignKey: 'parentId'});\r\nm.Category.belongsToMany(m.Category, {as: 'descendents', foreignKey: 'ancestorId', through: m.CategoryAncestor});\r\nm.Category.belongsToMany(m.Category, {as: 'ancestors', foreignKey: 'categoryId', through: m.CategoryAncestor});\r\n\r\n// results\r\n\r\n[\r\n\t{\r\n\t\tid: 3368,\r\n\t\tparentId: 1767,\r\n\t\thierarchyLevel: 6,\r\n\t\tancestors: [\r\n\t\t\t{\r\n\t\t\t\tid: 1767,\r\n\t\t\t\tparentId: 1763,\r\n\t\t\t\thierarchyLevel: 5,\r\n\t\t\t\tCategoryAncestor: {\r\n\t\t\t\t\tcategoryId: 3368,\r\n\t\t\t\t\tancestorId: 1767\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t]\r\n\t}\r\n]\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/overlookmotel/sequelize-hierarchy/issues/comments/238933335","html_url":"https://github.com/overlookmotel/sequelize-hierarchy/issues/71#issuecomment-238933335","issue_url":"https://api.github.com/repos/overlookmotel/sequelize-hierarchy/issues/71","id":238933335,"user":{"login":"overlookmotel","id":557937,"avatar_url":"https://avatars.githubusercontent.com/u/557937?v=3","gravatar_id":"","url":"https://api.github.com/users/overlookmotel","html_url":"https://github.com/overlookmotel","followers_url":"https://api.github.com/users/overlookmotel/followers","following_url":"https://api.github.com/users/overlookmotel/following{/other_user}","gists_url":"https://api.github.com/users/overlookmotel/gists{/gist_id}","starred_url":"https://api.github.com/users/overlookmotel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/overlookmotel/subscriptions","organizations_url":"https://api.github.com/users/overlookmotel/orgs","repos_url":"https://api.github.com/users/overlookmotel/repos","events_url":"https://api.github.com/users/overlookmotel/events{/privacy}","received_events_url":"https://api.github.com/users/overlookmotel/received_events","type":"User","site_admin":false},"created_at":"2016-08-10T17:03:23Z","updated_at":"2016-08-10T17:03:23Z","body":"That said, I guess when you pseudo-delete (\"paranoid\" delete) a row in `Categories` table, it should delete the row in `Categoriesancestors` too - and that's the fault of sequelize-hierarchy. I'd never considered what would happen when `paranoid` option is used.\r\n\r\nBut I think there's a sequelize bug involved here too."}}
{"actor":{"display_login":"overlookmotel"}}