- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在 MongoDB 中创建 Stitch 函数并得到未定义的结果而不是 double。
我正在开发一个 iOS 应用程序,使用 MongoDB 数据库。我正在创建 Stitch 函数,并使用 callFunction(withName:withArgs:_:) 方法。我编写了一个函数来计算平均早晨值。我想将早上的值返回给应用程序。下面是代码。
exports = function(DAY,MONTH){
var total = 0.0;
var count = 0.0;
var morning = 0.0;
var collection = context.services.get("mongodb-atlas").db("database_name").collection("collection_name");
var docs = collection.find({month: { $eq: MONTH },
day: { $eq: DAY },
hour: { $gte: 8 },
hour: { $lt: 13 }
}).toArray().then((data) => {
data.forEach((el) =>{
total = total + el.value;
count = count + 1.0;
});
morning = total/count;
console.log("morning");
console.log(morning);
return {morning};
})
.catch((error) => {
console.log(error);
return {morning};
});
};
“”“输出”“”
早上好869.5729166666666
result: { "$undefined": true } result (JavaScript): EJSON.parse('{"$undefined":true}')
"""-输出结束"""
我正在尝试返回双倍的早晨值,但是它返回 BSONUndefined。当我尝试从 iOS 应用程序获取结果时,我得到"""早上:BSONUndefined() """但在 return 语句之前,它会打印早上的值以正确缝合控制台。
最佳答案
以这种方式在 MongoDB find()
查询之前使用 return
语句
exports = function(DAY,MONTH){
var total = 0.0;
var count = 0.0;
var morning = 0.0;
var collection = context.services.get("mongodb-atlas").db("database_name").collection("collection_name");
return collection.find({month: { $eq: MONTH },
day: { $eq: DAY },
hour: { $gte: 8 },
hour: { $lt: 13 }
}).toArray().then((data) => {
data.forEach((el) =>{
total = total + el.value;
count = count + 1.0;
});
morning = total/count;
console.log("morning");
console.log(morning);
return {morning};
})
.catch((error) => {
console.log(error);
return {morning};
});
};
关于javascript - 如何修复 MongoDB Stitch 函数中的 "Result undefined",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56966667/
为什么我的 mongodb-stitch 服务会返回值的类型($numberLong、$numberInt,...),而 Compass 应用程序却没有? 如何使用与 Compas 中相同的变量格式,
我想使用 Firebase signInWithEmailAndPassword 在 mongodb Stitch 应用程序中对用户进行身份验证。是否可以? 我研究了使用 JWT 签名 key 的 S
我试图学习图像拼接背后的理论,并找到了关于如何仅拼接两个图像的文章。我阅读了很多关于拼接的论文,比如 Lowe,他代表了一篇关于图像拼接的伟大论文。但是总是缺少一件事,多个图像如何匹配?它是第一个图像
编辑(改写问题):我将如何使用提供的 smoothstep 函数在相邻的二维数组之间创建渐变?每个数组大小相同,包含介于 0 和 1 之间的值,通过单纯形噪声从边缘到边缘平滑过渡。因此,我希望相邻数组
题目地址:https://leetcode.com/problems/video-stitching/ 题目描述 Youare given a series of video clips from
我可以在 mongoDB Stitch 中看到限制选项 docs但无法找到我们如何跳过记录进行分页。 最佳答案 您可以将聚合与管道一起使用。类似的东西: exports = function(arg)
我正在使用 mongodb 的缝合后端来运行应用程序,当我尝试以匿名用户身份登录时,它会抛出此错误: failed to log in anonymously: { StitchError: auth
我有两个集合,我们称它们为 A 和 B。集合 A 存储的文档包含集合 B 中另一个文档的 ObjectId。 例如:{name: String, age: String, bObjectId: Obj
我正在尝试为我的所有文档取回一个字段。 我是 mongoDB 的新手,但我不明白为什么这不起作用。 var docs = db.collection("articles").find({}, { _i
刚开始玩Grunt并想使用 Stitch组合我的模块以供客户端使用。总的来说,我对 commonJS 没有太多经验,而且这两个库对我来说都是新手——所以请多多包涵。 这是我的 Grunt 文件的摘录:
如下页所述, https://docs.mongodb.com/stitch/import-export/create-stitch-app/ 我创建了一个名为 stitch.json 的文件,其中包
我在android项目中使用opencv拼接。 public class MainActivity extends Activity implements OnClickListener {
这是我之前 question 的后续. 据我了解 Haxl和 Stitch他们使用 monad 进行数据访问。 monad 实际上是一棵数据访问命令树。子节点是节点所依赖的命令。 sibling 是并
今年早些时候我试用了 MongoDB Stitch,当时感觉它还不像成品(例如,apps cannot be renamed)。我再试一次,这次我有兴趣了解如何使用 Jest ( this also
我正在使用 MongoDB Stitch 创建支持数据的 API,但是当我发出 GET 请求时,返回的数据显示为: "firstHit": { "$numberInt": "3" 我希望它们返回
这让我抓狂,我以前见过它,但无法复制或找到它或它的任何资源。我正在做的是一 strip 有皮革质地和“缝合图案”的垂直丝带。缝线的工作方式很简单,内部 div 带有虚线边框,甚至丝带形状也很容易使用伪
我是一名 Unity 开发人员,需要帮助同事在 Obj-C 中本地执行此操作。在 Unity 中,这没什么大不了的: 1)samples以float[]的List形式存储在内存中 2)对于任何给定的样
我正在使用 MongoDb Stitch Android SDK 向电子邮件/密码身份验证系统注册用户。 但是调用SDK中的register(name,pass)方法时出现404错误。 Unexpec
我已经能够使用 MongoDB Stitch 进行注册和登录,但我找不到如何更新用户数据。我试过查询 db.users 或 db.user 但这些不存在。 是否有更新用户的方法? 最佳答案 我与支持人
正在关注 MongoDB Custom Authentication , 给出任何 JWT Token使用以下最少的字段可与 MongoDB Stitch 身份验证一起使用。此外, token 需要由
我是一名优秀的程序员,十分优秀!