How to implement auto increment for mongodb in strapi?

i tried adding these mongoose plugins mongoose-auto-increment and mongoose-sequence to strapi in config/functions/mongoose.js.. the counter collections are getting created.. but the sequence counts are not getting updated.. Is there a way to get these plugins working or is there a way to implement it myself?

// config/functions/mongoose.js
var autoIncrement = require('mongoose-auto-increment');

module.exports = (mongoose, connection) => {

  var movieSchema = mongoose.Schema({
    title: String
  }, { collection : 'Tests' });

  movieSchema.plugin(autoIncrement.plugin, { model: 'Test', field: 'movieId', startAt: 1 });

92 thoughts on “How to implement auto increment for mongodb in strapi?”