{"action":"created","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/5292","repository_url":"https://api.github.com/repos/sequelize/sequelize","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/5292/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/5292/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/5292/events","html_url":"https://github.com/sequelize/sequelize/issues/5292","id":128401584,"number":5292,"title":"Unhandled rejection TypeError: val.replace is not a function","user":{"login":"tankerkiller125","id":3457368,"avatar_url":"https://avatars.githubusercontent.com/u/3457368?v=3","gravatar_id":"","url":"https://api.github.com/users/tankerkiller125","html_url":"https://github.com/tankerkiller125","followers_url":"https://api.github.com/users/tankerkiller125/followers","following_url":"https://api.github.com/users/tankerkiller125/following{/other_user}","gists_url":"https://api.github.com/users/tankerkiller125/gists{/gist_id}","starred_url":"https://api.github.com/users/tankerkiller125/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tankerkiller125/subscriptions","organizations_url":"https://api.github.com/users/tankerkiller125/orgs","repos_url":"https://api.github.com/users/tankerkiller125/repos","events_url":"https://api.github.com/users/tankerkiller125/events{/privacy}","received_events_url":"https://api.github.com/users/tankerkiller125/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2016-01-24T14:47:11Z","updated_at":"2016-06-03T11:52:28Z","closed_at":"2016-02-21T08:22:48Z","body":"I'm thinking that this is the same problem to #5082 however I will go ahead and post all of my code related to the model and the problem.\r\n\r\nModel:\r\n```javascript\r\n/* jshint indent: 2 */\r\n\r\nmodule.exports = function (sequelize, DataTypes) {\r\n    return sequelize.define('users', {\r\n        id: {\r\n            type: DataTypes.INTEGER(10),\r\n            allowNull: false,\r\n            primaryKey: true,\r\n            autoIncrement: true\r\n        },\r\n        email: {\r\n            type: DataTypes.STRING,\r\n            allowNull: false\r\n        },\r\n        password: {\r\n            type: DataTypes.STRING,\r\n            allowNull: false\r\n        },\r\n        permissions: {\r\n            type: DataTypes.TEXT,\r\n            allowNull: true\r\n        },\r\n        last_login: {\r\n            type: DataTypes.DATE,\r\n            allowNull: true\r\n        },\r\n        username: {\r\n            type: DataTypes.STRING,\r\n            allowNull: false\r\n        },\r\n        created_at: {\r\n            type: DataTypes.DATE,\r\n            allowNull: false,\r\n            defaultValue: '0000-00-00 00:00:00'\r\n        },\r\n        updated_at: {\r\n            type: DataTypes.DATE,\r\n            allowNull: false,\r\n            defaultValue: '0000-00-00 00:00:00'\r\n        },\r\n        deleted_at: {\r\n            type: DataTypes.DATE,\r\n            allowNull: true\r\n        }\r\n    }, {\r\n        tableName: 'users',\r\n        freezeTableName: true\r\n    });\r\n};\r\n```\r\nSetup:\r\n```javascript\r\nSequelize = require('sequelize');\r\norm = new Sequelize(config.get('mysql.database'), config.get('mysql.username'), config.get('mysql.password'), {\r\n    host: config.get('mysql.host'),\r\n    port: config.get('mysql.port'),\r\n    dialect: 'mysql',\r\n    define: {\r\n        timestamps: false\r\n    }\r\n});\r\n```\r\n\r\nUsage:\r\n```javascript\r\nvar mentions = function (message) {\r\n    var userModel = orm.import(__dirname + '/models/users.js');\r\n    // Match twitter like mentions\r\n    var usernames = message.match(/\\B@[a-z0-9_-]+/gi);\r\n    var realUsers = {};\r\n    // Verify that the user exist in the database\r\n    var verify = function(element, index, array) {\r\n        console.log(element);\r\n        userModel.find({\r\n            where: {\r\n                username: element.replace('@', '')\r\n            }\r\n        }).then(function(data) {\r\n            if(data != null) {\r\n                realUsers[data.username]\r\n            }\r\n        })\r\n    };\r\n    // If there are mentioned user check them!\r\n    if(usernames !== null) {\r\n        usernames.forEach(verify);\r\n        return realUsers;\r\n    } else {\r\n        // Return empty if there are no mentioned users.\r\n        return {};\r\n    }\r\n};\r\n```\r\n\r\nAnd actually calling the mention function:\r\n```javascript\r\nvar json = JSON.parse(data);\r\nvar mentionsObj = mentions(json.message);\r\n```"},"comment":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/comments/223559565","html_url":"https://github.com/sequelize/sequelize/issues/5292#issuecomment-223559565","issue_url":"https://api.github.com/repos/sequelize/sequelize/issues/5292","id":223559565,"user":{"login":"benjaminhon","id":8186376,"avatar_url":"https://avatars.githubusercontent.com/u/8186376?v=3","gravatar_id":"","url":"https://api.github.com/users/benjaminhon","html_url":"https://github.com/benjaminhon","followers_url":"https://api.github.com/users/benjaminhon/followers","following_url":"https://api.github.com/users/benjaminhon/following{/other_user}","gists_url":"https://api.github.com/users/benjaminhon/gists{/gist_id}","starred_url":"https://api.github.com/users/benjaminhon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjaminhon/subscriptions","organizations_url":"https://api.github.com/users/benjaminhon/orgs","repos_url":"https://api.github.com/users/benjaminhon/repos","events_url":"https://api.github.com/users/benjaminhon/events{/privacy}","received_events_url":"https://api.github.com/users/benjaminhon/received_events","type":"User","site_admin":false},"created_at":"2016-06-03T11:52:28Z","updated_at":"2016-06-03T11:52:28Z","body":"ah thanks, that makes more sense"}}
{"actor":{"display_login":"benjaminhon"}}