问题标签 [mongoose-q]

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 投票
1 回答
215 浏览

node.js - 寻找一种在 mongoose-q 中进行许多查询的更有效方法

我正在使用 mongoose-q(流行的 mongoose mongodb ORM for node.js 的 promise 包装器)。

然而,我觉得也许这些嵌套的承诺并不比回调好多少。

有没有更好的方法来做这些查询?

0 投票
0 回答
138 浏览

node.js - Mongoose-q 一直返回 null

节点菜鸟和第一次在这里问一个问题,所以我希望我做对了..

我使用https://github.com/jkvoorhis/userAuth作为我的代码格式化的基础,用 Mongoose 方法替换了 Orchestra。

每当我向 /register 发送 POST 请求时,我在节点窗口中的响应都会显示为:

当 MongoDB 中的文档存在时,为什么它会一直返回 null?有什么问题User.findOneQ({"username": username})吗?我搞砸了mongoose = require('mongoose-q')()吗?非常感谢。

应用程序.js:

Auth.js:

用户.js:

0 投票
1 回答
2392 浏览

node.js - 猫鼬删除后事件不会触发

我的模型中有这段代码:

这是我的控制器中的内容:

我希望当控制器中的功能运行时,模型中的功能应该发生。我可以在调试器中看到它根本不会触发。

我正在使用"mongoose": "3.8.23""mongoose-q": "0.0.16"

0 投票
1 回答
477 浏览

mongoose - difference between Query and Model mongoose

these days i'm trying to learn more about mongoose to implement it in my project ,while going through the doc , i saw both Model and Query, both have many methods in common ,my question is what is the difference between them for example

Model.findOne()vs Query.prototype.findOne(), and thank you in advance.

0 投票
1 回答
32 浏览

mongodb - MongoDB Find Query,根据文档中的键值动态更改搜索键

国家数据看起来像 -

我需要根据inEU字段设置为真或假来选择 x 或 y 对象。X 和 Y 对象具有相同的键(值/数据不同)。

如果为真,则查找查询必须使用 X 中的值,inEU否则使用 Y 对象进行搜索。

请让我知道它是否可能,如果是,请提供任何 URL/文档链接或任何小示例将对我有所帮助。