简体   繁体   English

解析服务器Java脚本云代码错误:[TypeError:必须使用ParseObject或类名称来构造ParseQuery。]

[英]Parse server Java script Cloud code Error : [TypeError: A ParseQuery must be constructed with a ParseObject or class name.]

I am trying to run a cloud code function to query the server and get a list of users from a class called ROOMS. 我正在尝试运行云代码功能来查询服务器并从名为ROOMS的类中获取用户列表。 I want to then use the value "USER" of the objects that are found to run another query in which I send push notifications to those users. 然后,我想使用找到的对象的值“ USER”来运行另一个查询,在该查询中我向这些用户发送推送通知。

Here is the code that I have so far, I am used to writing in SWIFT so I am not too good at javascript 这是到目前为止的代码,我习惯于在SWIFT中编写代码,所以我不太擅长javascript

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

  var userQuery = new Parse.Query(Parse.ROOMS);
  userQuery.equalTo("roomName",request.params.roomname);


  var message = request.params.message;
  var pushQuery = new Parse.Query(Parse.Installation);
  pushQuery.containedIn("user","USER",userQuery);   

  Parse.Push.send({
    where: pushQuery,
    data : { 
      alert: message,
      "badge": 1,
    }
    }, {
    success: function(result) {
    console.log(JSON.stringify(result));
    response.success(result);
    },
    error: function(error) {
    console.error(JSON.stringify(error));
    response.error(error.message)
    },
  useMasterKey: true

  });

});

I believe Parse.ROOMS does not exist try replacing with “ROOMS” if thst's The name of your collection. 我相信Parse.ROOMS不存在,请尝试使用“ ROOMS”代替,如果它是您的收藏名称。 Note that collection names are case sensitive. 请注意,集合名称区分大小写。

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

相关问题 “WebFormsBundle”不是有效的脚本名称。 名称必须以“.js”结尾 - 'WebFormsBundle' is not a valid script name. The name must end in '.js' 解析Cloud JS脚本-错误代码:141 - Parse Cloud JS Script - Error Code: 141 解析服务器云代码错误141:未经授权 - Parse Server Cloud Code Error 141: Unauthorized 发送推送通知时解析服务器云代码错误 - Parse Server Cloud Code error when sending push notification Parse.com云代码(服务器)和iOS(客户端)的自定义错误 - Custom error with Parse.com Cloud Code (server) and iOS (client) 流星运行iOS错误:验证程序包名称时出错。 程序包名称必须类似于:com.company.Name - Meteor run iOS error: Error validating package name. Package name must look like: com.company.Name 解析云代码httprequest错误 - Parse Cloud Code httprequest error 错误:TypeError:无法在“窗口”上执行“获取”:名称无效。 这里可能是什么问题? - Error: TypeError: Failed to execute 'fetch' on 'Window': Invalid name. What could be the issue here? Parse.com Cloud Code错误:TypeError:无法调用未定义的方法'get' - Parse.com Cloud Code error : TypeError: Cannot call method 'get' of undefined 将构造的类名传递给JQuery - Pass a constructed class name into JQuery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM