ramiel/mongoose-sequence

DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead

thearabbit opened this issue · 2 comments

I base on Meteor, Mongo@4.0.x, mongoose@5.6.13.

// Mongoose
import Mongoose from 'mongoose'
const MongoTypes = Mongoose.Schema.Types
const AutoIncrement = require('mongoose-sequence')(Mongoose)

const Mg_EmployeesSchema = new Mongoose.Schema({
  name: String,
  birthDate: Date,
  gender: String,
  address: {
    type: String,
  },
  decimalNum: {
    type: MongoTypes.Decimal128,
  },
  floatNum: {
    type: Number,
  },
})
Mg_EmployeesSchema.plugin(AutoIncrement, { inc_field: 'id' })

export const Mg_Employees = Mongoose.model('employees', Mg_EmployeesSchema)

Get

DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead

It's related to mongoose, it would happen also if you create index for your collection. You can read more here Automattic/mongoose#6890

Thanks for your reply.
I closed