问题标签 [mongoose-auto-increment]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
114 浏览

node.js - Node.js 文档中嵌套对象的 MongoDB 自动增量

我在 Mongo 中有一个模式,如下所示:

我想在 Node.js 中自动增加字段 requirementsId。我尝试使用 mongoose-auto-increment 包,但无法为嵌套对象创建自动增量。需要一些帮助。我的代码如下:

如何访问 requirementsId 字段?

0 投票
0 回答
42 浏览

javascript - 使用具有 autoIncrement.MongooseAutoIncrementId.plugin 业务的模型使用 Jest 模拟/存根数据。无法读取未定义的属性“Mongoose ....”

您好,我正在尝试编写一些单元测试,当我导入一些需要的接口来实现单元测试时,我一直遇到这个错误“无法读取未定义的属性 'MongoseAutoIncrementId'”。有一个模型,它的模式使用了插件

我真的不需要这个模型来实现单元测试,模型来自导入到我的项目的包,所以我不能删除自动增量业务或更改模型内的任何内容。

我的问题是我应该如何模拟数据和模型以便能够导入、声明服务或消费者对象而不会出现错误?

谢谢