我如何使用多个主键在SailsJS中制作模型?我需要它来阻止duplicates。
答案 0 :(得分:1)
答案 1 :(得分:0)
我通过在sails bootstrap上执行查询解决了我的问题
Query(`
ALTER TABLE \`word\` CHANGE \`id\` \`id\` INT(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE \`word\` ADD UNIQUE(\`id\`);
ALTER TABLE \`word\` CHANGE \`projectId\` \`projectId\` INT(11) NOT NULL;
ALTER TABLE \`word\` CHANGE \`caseId\` \`caseId\` INT(11) NOT NULL;
ALTER TABLE \`word\` CHANGE \`parent\` \`parent\` VARCHAR(255) NOT NULL;
ALTER TABLE \`word\` CHANGE \`word\` \`word\` VARCHAR(255) NOT NULL;
ALTER TABLE \`word\` CHANGE \`wordLower\` \`wordLower\` VARCHAR(255) NOT NULL;
ALTER TABLE \`word\` CHANGE \`negative\` \`negative\` TINYINT(1) NOT NULL;
ALTER TABLE \`word\` DROP PRIMARY KEY, ADD PRIMARY KEY(\`projectId\`, \`parent\`, \`wordLower\`);
`);