[英]meteor js simpleschema Index with pattern already exists with different options
I'm using meteor js w/ simple-schema and getting 我正在使用带有简单模式的流星js并获得
MongoError: Index with pattern: { username: 1 } already exists with different options
My schema around the db.users collection is 我围绕db.users集合的模式是
Schema = {};
Schema.User = new SimpleSchema({
...
username: {
type: String,
unique: true,
regEx: /^[a-z0-9]{3,32}$/ ,
max: 32,
min: 3 },
...
});
I've dropped the index in mongodb but am still getting the error when I restart my app. 我在mongodb中删除了索引,但是重新启动应用程序时仍然出现错误。 Anyone come across this ?
有人遇到这个吗?
Meteor comes with some default indexes on the users
collections. 流星自带的一些默认指标
users
集合。 From accounts-base : 从帐户基础 :
/// DEFAULT INDEXES ON USERS
Meteor.users._ensureIndex('username', {unique: 1, sparse: 1});
Meteor.users._ensureIndex('emails.address', {unique: 1, sparse: 1});
Meteor.users._ensureIndex('services.resume.loginTokens.hashedToken',
{unique: 1, sparse: 1});
Meteor.users._ensureIndex('services.resume.loginTokens.token',
{unique: 1, sparse: 1});
// For taking care of logoutOtherClients calls that crashed before the tokens
// were deleted.
Meteor.users._ensureIndex('services.resume.haveLoginTokensToDelete',
{ sparse: 1 });
// For expiring login tokens
Meteor.users._ensureIndex("services.resume.loginTokens.when", { sparse: 1 });
I have not checked but I'm guessing unique: true
may be the part of your schema that is conflicting with the above. 我没有检查,但我猜
unique: true
可能是你的架构是与上述相冲突的部分。
you can perfectly merge your schema with the existing one where index and unique is already set for username and email. 您可以将您的架构与现有的架构完美合并,在该架构中,已经为用户名和电子邮件设置了索引和唯一性。 as you only remove them by setting them explicitly to false they will remain.
因为您仅通过将它们显式设置为false来删除它们,否则它们将保留。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.