sails v0.10.0-rc7 unique constraint not working

别等时光非礼了梦想. 提交于 2019-12-24 04:20:27

问题


I upgraded my sails from rc4 to rc7 today, and the unique constraint on my model stopped working. note that in rc4 it used to work perfectly. and sails-mongo version on both versions i tried is: "sails-mongo": "^0.10.0-rc5"

Model attribute:

    emailAddress: {
        type: 'email',
        required: true,
        unique: true
    },

any issues?


回答1:


As already stated it's a bug in waterline/sails-mongo

I however advise against setting syncable to true as it was set to false by the developers for a reason (the github bug report explains more, also already stated igor)

If you require uniqueness you can just create an index in the DB manually. Not a great solution if you're deploying to different environments, but as a temporary work around it'll do.

http://docs.mongodb.org/manual/tutorial/create-a-unique-index/

After all, we're using an RC for a piece of software at version 0.10, this kind of thing should be expected.




回答2:


Although it's month old, just came here from Google, so for the reference, it is apparently known issue (check here for details: https://github.com/balderdashy/sails-mongo/issues/152)

As It's mentioned there, you can quick-fix this by setting

syncable = true

though that might imply some other problems (auto-migrating on no-sql databases)



来源:https://stackoverflow.com/questions/23835136/sails-v0-10-0-rc7-unique-constraint-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!