Questions tagged [mongoose-sequence]

10 questions
10
votes
1 answer

What does "can only be default-imported using the 'esModuleInterop' flag" mean?

I am getting the following error: lib/app.ts:1:8 - error TS1259: Module '"mongoose-sequence"' can only be default-imported using the 'esModuleInterop' flag on the following line of code: import _ from 'mongoose-sequence'; Now, I'm happy to admit…
Nick Hodges
  • 16,902
  • 11
  • 68
  • 130
6
votes
3 answers

Auto Increment Sequence in NestJs/Mongoose

I'm migrating a NodeJs project to NestJs, this project uses MongoDB as back-end database and Mongoose as ODM. I was using the mongoose-sequence plugin to handle autoincrement sequences, however I'm facing troubles requiring the library under…
Andres Felipe
  • 625
  • 7
  • 24
3
votes
0 answers

mongoose-sequence reset the id after testing

I am trying to use mongoose-sequence, I did some test but once i use the "id" field i created again with new sequence it gives the error : throw new Error(Counter already defined for field "${id}"); Also i am trying to set the start_seq attribute…
1
vote
1 answer

Mongoose Sequence not inserting autoincrement NodeJS

Trying to make a field auto-increment I use Mongoose Sequence but it never auto-increments as Mongoose always throws me the following error: Error: Product validation failed: idProduct: Cast to Number failed for value "undefined" (type string) at…
OscarDev
  • 917
  • 14
  • 34
1
vote
0 answers

Pre Function is not called (Using it to auto increment a variable but it's not working)

This is my pre function declaration locationSchema.pre('save', function(next) { console.log(" HELLO ") //not printing var doc = this; Counter.findByIdAndUpdate({_id: 'location_id'}, {$inc: {seq: 1} }, {upsert: true , new: true},…
Rana
  • 55
  • 5
1
vote
4 answers

How do I use the mongoose-sequence project in TypeScript?

I am trying to build a REST API server with an auto-incrementing field with Mongoose, Express, and TypeScript using the mongoose-sequence project. (This project seems like the most popular and supported of the ones out there.) I have run npm…
Nick Hodges
  • 16,902
  • 11
  • 68
  • 130
0
votes
0 answers

Auto Increment Sequence in NestJs/Mongoose failed because of @type check

guys. I'm using a provider(useFactory) to register mongoose-sequence plugin for my User Schema, but it doesn't work because of @type check. This is my module. import { Module } from '@nestjs/common'; import { MongooseModule, getConnectionToken }…
cityvoice
  • 2,409
  • 4
  • 14
  • 25
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 =…
0
votes
1 answer

reset counter per day mongoose-sequence

I have a mongoose user schema. seq_no is an auto-incremented field - if the same country and city user is created it is incremented. const mongoose = require("mongoose"); const AutoIncrement = require("mongoose-sequence")(mongoose); UserSchema =…
Hiccup
  • 596
  • 6
  • 19
0
votes
1 answer

NestJS and Mongoose Using Mongoose-Sequence

I am attempting to utilize the plugin 'mongoose-sequence' with my NestJS application. I wish for this plugin to be useable by all the modules I will be creating for this application. Here's my app.module.ts: import { Module } from…
Todd
  • 698
  • 6
  • 19