mongoose-sequence

Auto Increment Sequence in NestJs/Mongoose

陌路散爱 提交于 2021-01-27 14:40:47
问题 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 NestJs. The mongoose-sequence documentation explains how to import the library using CommonJS syntax as follows: const mongoose = require('mongoose') const AutoIncrementFactory = require('mongoose-sequence'); const connection = await mongoose

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

孤者浪人 提交于 2020-03-22 06:39:08
问题 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 I'm missing something with the whole "underscore as a function name" thing, but the error makes no sense, as the esModuleInterop flag is absolutely, positively set to true in my ts.config file. I am trying to import this: declare module 'mongoose