Auto increment plugin nextCount not found
Just use ObjectId
and set _id
for every chat message before saving batch:
const mongoose = require('mongoose');const ObjectId = mongoose.Types.ObjectId;messages.forEach(message => { message._id = message._id || ObjectId()})// call you method which save batchessaveBatch(messages)