{"action":"created","issue":{"url":"https://api.github.com/repos/balderdashy/sails-mongo/issues/290","labels_url":"https://api.github.com/repos/balderdashy/sails-mongo/issues/290/labels{/name}","comments_url":"https://api.github.com/repos/balderdashy/sails-mongo/issues/290/comments","events_url":"https://api.github.com/repos/balderdashy/sails-mongo/issues/290/events","html_url":"https://github.com/balderdashy/sails-mongo/issues/290","id":83120510,"number":290,"title":"sails-mongo 0.11.2 unique validation not working!","user":{"login":"luisincrespo","id":4452976,"avatar_url":"https://avatars.githubusercontent.com/u/4452976?v=3","gravatar_id":"","url":"https://api.github.com/users/luisincrespo","html_url":"https://github.com/luisincrespo","followers_url":"https://api.github.com/users/luisincrespo/followers","following_url":"https://api.github.com/users/luisincrespo/following{/other_user}","gists_url":"https://api.github.com/users/luisincrespo/gists{/gist_id}","starred_url":"https://api.github.com/users/luisincrespo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luisincrespo/subscriptions","organizations_url":"https://api.github.com/users/luisincrespo/orgs","repos_url":"https://api.github.com/users/luisincrespo/repos","events_url":"https://api.github.com/users/luisincrespo/events{/privacy}","received_events_url":"https://api.github.com/users/luisincrespo/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-05-31T15:56:08Z","updated_at":"2015-09-10T18:39:45Z","closed_at":"2015-07-01T02:34:31Z","body":"I'm using sails 0.11 and sails-mongo 0.11.2 adapter.\r\n\r\nI have a user model with a nickname, and I want the nickname to be unique among every user. I specify the attribute as unique like this:\r\n\r\n    nickname: {\r\n       type: 'string',\r\n       unique: true\r\n    }\r\n\r\nIt is not working, I can add two users with the same nickname without a problem!!"},"comment":{"url":"https://api.github.com/repos/balderdashy/sails-mongo/issues/comments/139338787","html_url":"https://github.com/balderdashy/sails-mongo/issues/290#issuecomment-139338787","issue_url":"https://api.github.com/repos/balderdashy/sails-mongo/issues/290","id":139338787,"user":{"login":"gayanhewa","id":1681406,"avatar_url":"https://avatars.githubusercontent.com/u/1681406?v=3","gravatar_id":"","url":"https://api.github.com/users/gayanhewa","html_url":"https://github.com/gayanhewa","followers_url":"https://api.github.com/users/gayanhewa/followers","following_url":"https://api.github.com/users/gayanhewa/following{/other_user}","gists_url":"https://api.github.com/users/gayanhewa/gists{/gist_id}","starred_url":"https://api.github.com/users/gayanhewa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gayanhewa/subscriptions","organizations_url":"https://api.github.com/users/gayanhewa/orgs","repos_url":"https://api.github.com/users/gayanhewa/repos","events_url":"https://api.github.com/users/gayanhewa/events{/privacy}","received_events_url":"https://api.github.com/users/gayanhewa/received_events","type":"User","site_admin":false},"created_at":"2015-09-10T18:39:45Z","updated_at":"2015-09-10T18:39:45Z","body":"Adding the unique index creates the index on mongodb side , but there is no validation message given if we are using blueprint methods with a model. Any idea how to handle this situation ? Without the server hangs.\r\n\r\n```\r\nUnhandled rejection [Error (E_UNKNOWN) Encountered an unexpected error] Details:  WriteError({\"code\":11000,\"index\":0,\"errmsg\":\"insertDocument :: caused by :: 11000 E11000 duplicate key error index: user-service.users.$username_1  dup key: { : \\\"gayan123\\\" }\",\"op\":{\"username\":\"gayan123\",\"email\":\"gayan123@mailinator.com\",\"password\":\"$2a$10$IW5gor2a6qMj3SXzcePmRu8yUXDrDmlj/R4PRADa9lofjxsKPQVg6\",\"first_name\":\"Neomal\",\"createdAt\":\"2015-09-10T18:10:49.699Z\",\"updatedAt\":\"2015-09-10T18:10:49.699Z\",\"_id\":\"55f1c7a96627e58061c7c914\"}})\r\n\r\n```\r\n\r\nThe error on mongodb side is valid but , why doesn't it get translated to sailsjs validation compatible format ?"}}