简体   繁体   English

解析云代码找不到我的数据

[英]Parse Cloud Code isn't finding my data

I am trying to do some simple stuff with CloudCode on my data; 我正在尝试对数据使用CloudCode做一些简单的事情; I've been through all of the documentation, and followed all of the instructions, and nothing is working. 我已经阅读了所有文档,并遵循了所有说明,但没有任何效果。

In my Data Browser, I have a class called "ChallengePostComment", that currently has 9 entries. 在我的数据浏览器中,我有一个名为“ ChallengePostComment”的类,当前有9个条目。 I am trying to write a simple function that will query that table, return all values, then loop through them to perform some operations. 我试图编写一个简单的函数来查询该表,返回所有值,然后遍历它们以执行一些操作。 But I can't even get it to return any data. 但是我什至无法得到它返回任何数据。 Here is my function: 这是我的功能:

var ChallengePostComment = Parse.Object.extend("ChallengePostComment");

Parse.Cloud.define("generate_comment_notifications", function(request, response) {

console.log("request = " + JSON.stringify(request));
var query = new Parse.Query(ChallengePostComment);
query.find().then(function(results) {
  console.log("results = " + JSON.stringify(results));
  response.success("Completed. " + results.length + " results.");
},
function(error) {
  console.log("Error: " + error.code + " " + error.message);
  response.error("Error: " + error.code + " " + error.message);
});

});

As you can see, right now all it does is perform the query, log the results, and return the count of the results. 如您所见,现在所做的只是执行查询,记录结果并返回结果计数。 But I always get 0 results. 但是我总是得到0个结果。

Here is how I'm calling the function from curl: 这是我从curl调用函数的方式:

curl -X POST \
     -H "X-Parse-Application-Id: <my app id>" \
     -H "X-Parse-REST-API-Key: <my rest api key>" \
     -H "Content-Type: application/json" \
     -d '{}' \
     https://api.parse.com/1/functions/generate_comment_notifications

Can someone please tell me what I'm doing wrong? 有人可以告诉我我在做什么错吗? I'm about to lose my mind here. 我将在这里失去理智。

Well, I feel stupid. 好吧,我很傻。 It turns out I had a typo in my Class definition, so the name I was looking for wasn't the name that actually existed in the database. 事实证明,我在Class定义中有一个错字,所以我要查找的名称不是数据库中实际存在的名称。 My mistake. 我的错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM