Questions tagged [mongoose-auto-increment]
15 questions
4
votes
2 answers
how can I create a auto-increment field in mongoose
can any one tell me how can I create a auto-increment field in mongoose without using any library or plugin. Any simple and easy way..

lakshmankashyap
- 437
- 1
- 5
- 14
3
votes
0 answers
Issue with mongoose-auto-increment plugin in nested models
I am trying to increment the value of procedureid & doctorId whenever the api call is being fired. I am using the below syntax. However, it's giving an error Treatment.procedureid_1 dup key when the second time I call the api through browser.
i…

Sona Shetty
- 997
- 3
- 18
- 41
2
votes
0 answers
Mock/stub data with Jest with models that have autoIncrement.MongooseAutoIncrementId.plugin business. Cannot read property 'Mongoose....' of undefined
Hello I am trying to write some unit test and while I import some needed interface to implement the unit testing I keep run into this error " Cannot read property 'MongoseAutoIncrementId' of undefined".
There is a model that its schema used the…

Noelia
- 89
- 10
1
vote
0 answers
MongoDB Auto-increment for a nested Object in a document in Node.js
I've a schema in Mongo like below:
({
title: String,
genre: String,
publishDate: Date,
index:Number,
requirementInformation:{
requirementInformationStatus:{
type: String,
required: true
},
…

user3003367
- 31
- 1
- 12
1
vote
1 answer
TypeError: connection.model is not a function in mongoose-auto-increment
I tried to connect mongodb. But I couldn't it. I thought [autoIncrement.initialize] is problem, but I couldn't solve the problem. This is my code.
const mongoose = require('mongoose');
const autoIncrement =…

ㄴㅇㅇ
- 67
- 2
- 4
- 8
1
vote
1 answer
Auto incrementing an indexed field in mongodb when there are multiple concurrent requests
I am trying to auto increment an indexed field in mongodb whenever there is an insertion happens, I read many posts on SO this and mongoose-auto-increment, but I am not getting how are they working Because consider below scenario
Suppose I want to…

Sudhanshu Gaur
- 7,486
- 9
- 47
- 94
0
votes
2 answers
MongooseError: Model.findOne() no longer accepts a callback && userSchema.plugin(autoIncrement.plugin, 'user');
import mongoose from "mongoose";
import autoIncrement from "mongoose-auto-increment";
const userSchema = mongoose.Schema({
name: String,
username: String,
email: String,
phone:…
0
votes
0 answers
(mongoose-sequnce)(mongoose) + Hapijs Adding auto increment in schema field
I want to add an auto-increment field in the MongoDB schema for
Interview.round.count field i.e. whenever I will Update the interview field it will automatically increase the Count value with +1
//Here is My Schema Field
const mongoose =…

RK Varun
- 61
- 5
0
votes
0 answers
How to generate auto increment count field using Mongodb Schema
I have a database related to the interview process which consists of multiple fields.
basically, there are 5 APIs
POST - (Candidate info) - for entering candidate data
PATCH - for updating candidate info
PATCH - (for Short Listing and reviewing) -…

RK Varun
- 61
- 5
0
votes
0 answers
nodeJS + mongodb auto-increment: cannot alter req.body during POST
I'm an experienced developer teaching myself nodeJS, I'm having some struggles.
I've read discussions on the following topic that you will likely refer me to, but they don't seem to work for me. After much trial and error, I'm in the situation…

raywright1
- 28
- 1
- 5
0
votes
1 answer
Using mongoose-autoincrement with insertMany request populates the _id index in a disordered manner
I am using mongoose-plugin-autoinc, a "a fork of mongoose-auto-increment
which has not been maintained in a while" to created auto-generated index _id starting from 0 for each document inserted in my collection.
Here are my two main files: …

AG_HIHI
- 1,705
- 5
- 27
- 69
0
votes
3 answers
Node.js Auto Increment E11000 duplicate key error collection
I'm struggling with Error E11000 duplicate key error collection, I have a schema with another sub-schema array and when I try to insert my schema with the empty array I allways get this error. I tried to set it undefined on pre-save without…

John
- 1,697
- 4
- 27
- 53
0
votes
1 answer
mongoose-auto-increment create index for custom id field
Im using mongoose-auto-increment to create and increase my item id. I would like to create index for this id but I haven't found a wayto achieve, insofar as I can look up on the Internet. Does anybody have any experience on creating an index for the…

J. C
- 89
- 11
0
votes
1 answer
Mongoose model not saving for some reason
I've create a Mongoose model and I wrote some code to test if it works, I tried to save the model and then display all of the models but it doesn't log anything to the console and the model isn't saving.
My testing code:
let User =…
user6766561
-2
votes
1 answer
Auto-Incrementing Sequence Field Mean Stack
I have a collection created for maintaining ticket_no, for which document looks like this,
{
id:"TICKET_ID",
TICKET_NO:7
}
Now, when I try to findOneAndUpdate for a ticket_id, incrementing TICKET_NO by 1,
function get(){
var ret =…

Sufail Kalathil
- 558
- 6
- 21