这是我的数据,包括书籍收藏,以及books.reviews子集合.
books = [{
_id: ObjectId("5558f40ad498c653748cf045"),
title: "Widget XYZ",
isbn: 1234567890,
reviews: [
{
_id: ObjectId("5558f40ad498c653748cf046"),
userId: "01234",
rating: 5,
review: "Yay, this great!"
},
{
_id: ObjectId("5558f40ad498c653748cf047"),
userId: "56789",
rating: 3,
review: "Meh, this okay."
}
]
}]
Run Code Online (Sandbox Code Playgroud)
在Node.js中(使用Mongoose),我需要用户能够通过表单提交评论,将评论和书籍的isbn发送到服务器,具有以下条件:
我可以通过4个单独的查询来完成此操作,但我知道这不是最佳的.我可以使用的查询数量最少(当然,这些查询是什么)?
我在标准配置中使用 ESLint。
运行时出现此错误eslint --fix */**:
Line number out of range (line 318 requested, but only 317 lines present).
RangeError: Line number out of range (line 318 requested, but only 317 lines present).
at SourceCode.getIndexFromLoc (/usr/local/lib/node_modules/eslint/lib/util/source-code.js:389:19)
at Object.fix (/usr/local/lib/node_modules/eslint/lib/rules/no-multiple-empty-lines.js:116:52)
at RuleContext.report (/usr/local/lib/node_modules/eslint/lib/rule-context.js:127:34)
at Program:exit.allLines.reduce.concat.reduce (/usr/local/lib/node_modules/eslint/lib/rules/no-multiple-empty-lines.js:108:37)
at Array.reduce (native)
at EventEmitter.Program:exit (/usr/local/lib/node_modules/eslint/lib/rules/no-multiple-empty-lines.js:93:22)
at emitOne (events.js:101:20)
at EventEmitter.emit (events.js:191:7)
at NodeEventGenerator.applySelector (/usr/local/lib/node_modules/eslint/lib/util/node-event-generator.js:265:26)
at NodeEventGenerator.applySelectors (/usr/local/lib/node_modules/eslint/lib/util/node-event-generator.js:294:22)
Run Code Online (Sandbox Code Playgroud)
任何想法如何解决这一问题?
我standard --fix首先从标准 CLI尝试并得到相同的错误,然后直接从 ESLint 尝试以确认这是后者抛出的错误,而不是前者。