[英]Error while using context in Mongo-Atlas Stitch
I'm trying to create a stitch for a Mongo-Atlas cluster.我正在尝试为 Mongo-Atlas 集群创建一个针迹。
Here is the simple webhook function这是简单的 webhook 函数
exports = function(payload) {
const mongodb = context.services.get("mongodb-atlas");
const cyber = mongodb.db("cyber");
};
unfortunately running this gives me the error不幸的是运行这给了我错误
TypeError: Cannot access member 'db' of undefined
类型错误:无法访问未定义的成员“db”
trace: TypeError: Cannot access member 'db' of undefined at exports (function.js:4:18) at apply () at function_wrapper.js:3:10 at :12:1
跟踪:类型错误:无法访问未定义的成员“db”在出口(function.js:4:18)在应用()在function_wrapper.js:3:10在:12:1
Basically the first get call returns mongodb
as undefined
.基本上,第一个 get 调用将
mongodb
返回为undefined
。
Anybody has run into this issue?有人遇到过这个问题吗?
Ok this was silly.好吧,这很愚蠢。
The context name for my cluster was not "mongodb-atlas"
but rather "mongodb-atlas-production"
我的集群的上下文名称不是
"mongodb-atlas"
而是"mongodb-atlas-production"
If you are at MongoDb-Atlas, u can try first reading the documentation appended in your function definition.如果您在 MongoDb-Atlas,您可以尝试先阅读附加在您的函数定义中的文档。
Functions run by Triggers are run as System users and have full access to Services, Functions, and MongoDB Data.
触发器运行的函数以系统用户身份运行,并拥有对服务、函数和 MongoDB 数据的完全访问权限。 [...] Note: In Atlas Triggers, the service name is defaulted to the cluster name.
[...]注意:在 Atlas Triggers 中,服务名称默认为集群名称。
It means that your SERVICE_NAME
is the name of your Cluster .这意味着您的
SERVICE_NAME
是您的Cluster的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.