查找具有字段值的对象(这是一个指针)

Find objects with field value (this is a pointer)

本文关键字:一个 指针 字段 对象 查找      更新时间:2023-12-22

我有一个类,比如"inspection",并且有一个字段名称属性(这是一个指针)。我正在尝试按字段值检索记录,但结果一无所获。我正在使用以下代码

getInspectionByProperty = function(req) {
    console.log(req.body.propertyId)
            var query = new Parse.Query("Inspection");
            query.include('property');
            query.equalTo('property', req.body.propertyId);
            query.find({
              success: function(data) {
                    console.log('in success'); 
                    console.log(data);
                // Successfully retrieved the object.
              },
              error: function(error) {
                console.log('in error')
                console.log("Error: " + error.code + " " + error.message);
              }
             });
    };

我在分析日志中得到这个错误

错误:102指针字段属性需要指针值

我如何才能获得记录。提前感谢

这是我尝试的,对我有用。

getInspectionByProperty = function(req) {
console.log(req.body.propertyId)
        var query = new Parse.Query("Inspection");
        query.include('property');
        query.equalTo("property", {
                    "__type": "Pointer",
                    "className": "Property",
                    "objectId": propertyId
                    });
        query.find({
          success: function(data) {
                console.log('in success'); 
                console.log(data);
            // Successfully retrieved the object.
          },
          error: function(error) {
            console.log('in error')
            console.log("Error: " + error.code + " " + error.message);
          }
         });
};