New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoError: The field 'required' is not valid for an index specification #74

Open
Siddeshgad opened this Issue Oct 3, 2017 · 15 comments

Comments

Projects
None yet
@Siddeshgad

Siddeshgad commented Oct 3, 2017

Unhandled rejection MongoError: The field 'required' is not valid for an index specification. Specification: { ns: "xyz.identitycounters", key: { field: 1, model: 1 }, name: "field_1_model_1", unique: true, required: true, index: -1, background: true }
at Function.MongoError.create (.../node_modules/mongodb-core/lib/error.js:31:11)
at .../node_modules/mongodb/lib/db.js:1093:80
at .../node_modules/mongodb-core/lib/connection/pool.js:469:18
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)

This statement was executed
identitycounters.createIndex({ field: 1, model: 1 }, { unique: true, required: true, index: -1, background: true })

https://docs.mongodb.com/manual/reference/method/db.collection.createIndex/
As per the definitions listed above, it does not contain required property.

I have already sent a PR for the above changes
#73

Thank you.

@highfeed

This comment has been minimized.

highfeed commented Oct 9, 2017

Hi. Fix it, please.

@yuk320

This comment has been minimized.

yuk320 commented Oct 9, 2017

index has the same problem
message: 'The field 'index' is not valid for an index specification. Specification: { ns: "epf.identitycounters", key: { field: 1, model: 1 }, na
me: "field_1_model_1", unique: true, index: -1, background: true }'

@highfeed

This comment has been minimized.

highfeed commented Oct 9, 2017

Just use mongoose-sequelize.

papaiatis added a commit to papaiatis/mongoose-auto-increment that referenced this issue Oct 22, 2017

Fixing Schema#index() call
The second parameter of Schema#index() call is passed to MongoDB API and index creation options but neither `required` or `index` is a valid option so I removed both.
Fixing bugs:
chevex-archived#76
chevex-archived#74
@pulselife

This comment has been minimized.

pulselife commented Dec 11, 2017

How to fix this bug?

@XBeg9

This comment has been minimized.

XBeg9 commented Dec 15, 2017

+1

@HansITChange

This comment has been minimized.

HansITChange commented Dec 21, 2017

Any updates on this ? Still not working...

@stephengardner

This comment has been minimized.

stephengardner commented Dec 28, 2017

Hey the fix here has been PRd, what's going on here? This needs a merge

@germanurrus

This comment has been minimized.

germanurrus commented Jan 4, 2018

I'm having the same issue, running the app over Docker...over Ubuntu in a real machine does not show the error, it only happens on a docker container. Please fix it. Thanks

@trueter

This comment has been minimized.

trueter commented Jan 5, 2018

+1!

@pandashuai

This comment has been minimized.

pandashuai commented Jan 9, 2018

+1

1 similar comment
@VunterSlaush

This comment has been minimized.

VunterSlaush commented Jan 11, 2018

+1

@raphaelsoul

This comment has been minimized.

raphaelsoul commented Jan 13, 2018

same problem using mongodb 3.6, seems due to mongo version. But is there anyone still maintaining this project?

@Koronos

This comment has been minimized.

Koronos commented Jan 14, 2018

Same error, I think if @chevex doesn't appear, is necessary create a new project to maintain this plugin. He has not activity since Dec 11, and there are pull request whit the solution. What should we do in these cases?

Update

Searching in github, I found a branch updated whit this issue fixed, the package is named mongoose-auto-increment-fix, works like the original package, the only change that you need do is change the import from: import autoIncrement from 'mongoose-auto-increment' to import autoIncrement from 'mongoose-auto-increment-fix'. For the moment works well in my project. I Hope this help you.

@nodkz

This comment has been minimized.

nodkz commented Jan 21, 2018

New maintained package https://github.com/nodkz/mongoose-plugin-autoinc
It fixes this error and bunch of others.

CodingSpiderFox added a commit to CodingSpiderFox/pantry-for-good that referenced this issue Mar 18, 2018

jspaine added a commit to freeCodeCamp/pantry-for-good that referenced this issue Mar 19, 2018

fix issue in test "admins can set other users as admins" (#367)
* fix issue in test "admins can set other users as admins" caused by mongodb exception on saving user (see chevex-archived/mongoose-auto-increment#74)

* adapted according to remarks from #367 (comment)
@nomanbiniqbal

This comment has been minimized.

nomanbiniqbal commented Jul 19, 2018

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment