在用户的云代码中级联删除

时间:2014-08-01 17:51:11

标签: javascript parse-platform

我尝试在删除用户时触发级联删除,但find()找不到相关项目似乎没有运行。

我的钩子如下:

Parse.Cloud.beforeDelete(Parse.User, function(request, response) {
  var user = request.object;
  console.log('User is ' + JSON.stringify(user));

  var checkInQuery = new Parse.Query('checkIn');
  checkInQuery.equalTo('user', user);
  console.log('Query is ' + JSON.stringify(checkInQuery));
  checkInQuery.find().then(function (checkIns) {
    console.log('Success');
    Parse.Object.destroyAll(checkIns);
  },
  function(error) {
    console.log('Error');
    console.error('Failed to delete user checkins: ' + JSON.stringify(error));
  });
  response.success();
});

我想用它来删除checkIn表中属于要删除用户的所有实例。但是,当我查看我的日志时,我看到:

I2014-08-01T17:48:05.807Z] User is {"username":"user_test_103075160","objectId":"t4vtXULwo9","createdAt":"2014-08-01T17:48:00.690Z","updatedAt":"2014-08-01T17:48:02.186Z"}
I2014-08-01T17:48:05.809Z] Query is {"where":{"user":{"__type":"Pointer","className":"_User","objectId":"t4vtXULwo9"}}}

checkInQuery.find()的答案没有任何内容。我希望根据日志消息看到SuccessError

0 个答案:

没有答案