I am trying to deploy the following code in firebase function but getting the following error :
Error: Failed to load function definition from source: Failed to generate manifest from function source: Error: Counter already defined for field "notification_id"
When removing the notification_id the deployment is taking place successfully but as soon as I add notification_id it shows the error.
If someone can please help me resolve this issue.
node.js
const mongoose = require('mongoose');
const AutoIncrement = require('mongoose-sequence')(mongoose);
const userProjectSurveySchema = new mongoose.Schema({
userId:
{
type: Number,
required: true,
trim: true
},
notification_id:
{
type: Number,
},
notification_type:
{
type: Number,
required: true,
},
status:
{
type: String,
required: true
},
questions: [
{
qn: {
type: String,
required: true
},
options: [
{
option: {
type: String
},
totalViews: {
type:Number
}
}
]
},
],
created_at: {
type: Date,
required: true,
default: Date.now(),
},
});
userProjectSurveySchema.plugin(AutoIncrement, {inc_field: 'notification_id'});
module.exports = mongoose.model('UserProjectSurveyDetails', userProjectSurveySchema);