-
-
Notifications
You must be signed in to change notification settings - Fork 56
Description
I've been trying to make this work with two schemas in my app and I cant seem to figure it out. I found a reference to someone else with an issue here and used their solution as a guide but its not working. I have 2 schemas set up, "userSchema" and "petSchema". Below each schema I have:
userSchema.plugin(AutoIncrement, {collection_name: 'counters'});
and
petSchema.plugin(AutoIncrement, {collection_name: 'petCounters'});
as a part of them both, the schemas have:
id: {
type: Number,
primaryKey: true
},
But when I try to use the schemas, I get this error:
C:\Users\ponyp\Desktop\MiwV2\node_modules\mongoose-sequence\lib\sequence.js:170
throw new Error('Auto increment field already present and not of type "Number"');
^
Error: Auto increment field already present and not of type "Number"
at SequenceFactory.Sequence._createSchemaKeys (C:\Users\ponyp\Desktop\MiwV2\node_modules\mongoose-sequence\lib\sequence.js:170:13)
at SequenceFactory.Sequence.enable (C:\Users\ponyp\Desktop\MiwV2\node_modules\mongoose-sequence\lib\sequence.js:112:10)
at SequenceFactory.Sequence.getInstance (C:\Users\ponyp\Desktop\MiwV2\node_modules\mongoose-sequence\lib\sequence.js:95:14)
at Schema.plugin (C:\Users\ponyp\Desktop\MiwV2\node_modules\mongoose\lib\schema.js:1430:3)
at Object. (C:\Users\ponyp\Desktop\MiwV2\APP.JS:61:12)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
Can you please help me figure out what's going wrong? I am still a beginner and I'm having a hard time figuring out what's up. I gather it's not giving the newly made pet an ID number but I can't tell why.