Coder Social home page Coder Social logo

Comments (8)

ramiel avatar ramiel commented on May 14, 2024 4

You can have the same name for two fields, but specify a different id for the counter.

FirstSchema = mongoose.Schema({
    ...
    internalCode: Number
});
FirstSchema.plugin(AutoIncrement, {id:'firstSchemaInternalCodeCounter', inc_field: 'internalCode'});

SecondShema = mongoose.Schema({
    ...
    internalCode: Number
});
SecondShema.plugin(AutoIncrement, {id:'secondSchemaInternalCodeCounter', inc_field: 'internalCode'});

from mongoose-sequence.

ramiel avatar ramiel commented on May 14, 2024

Did it solve your problem?

from mongoose-sequence.

eliflores avatar eliflores commented on May 14, 2024

Hi @ramiel !
I had this same issue and it worked for me! Thank you!! ☀️

from mongoose-sequence.

ramiel avatar ramiel commented on May 14, 2024

Glad to hear. I close this issue now

from mongoose-sequence.

jdriesen avatar jdriesen commented on May 14, 2024

Hi @ramiel

I encountered the same problem, and also for me, this solution worked.
Just as an idea... maybe you should update the docu a little bit ...
Something like ...

UserSchema.plugin(AutoIncrement, { id: '<unique_name_for_this_schema_counter>', inc_field: 'ID' });

I guess this would help a lot of devs ...

Great Plugin BTW... Thanks for sharing your knowledge !

Kind regards,
Johnny Driesen
Belgium

from mongoose-sequence.

ramiel avatar ramiel commented on May 14, 2024

Good suggestion @jdriesen. I will, for sure. In a future version id will be mandatory and this problem will go away

from mongoose-sequence.

dandv avatar dandv commented on May 14, 2024

I also ran into this problem. Any plans to make id mandatory?

from mongoose-sequence.

ramiel avatar ramiel commented on May 14, 2024

Actually yes. Any PR welcome :)

from mongoose-sequence.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.