ramiel/mongoose-sequence

Incrementing _id field special to mongoose doesn't work

makindiilete opened this issue · 1 comments

I followed your guide to do this
UserSchema = mongoose.Schema({
_id: Number,
name: String
}, { _id: false });
UserSchema.plugin(AutoIncrement);

But I keep getting error that "Cast to number failed for value " {name : Michael} " at path _id for model Hotel

Can you please post more code, from the schema definition to the prt where you save the document? A minimal replicable code maybe.
There's a test in the library that shows this and I just checked and it works. Also, in your issue the error reported is Cast to number failed for value " {name : Michael} " at path _id for model Hotel but the schema seems related to Users, not Hotels.