Cloudkit JS查询过滤器由recordName给出错误

时间:2015-12-08 18:54:17

标签: cloudkit cloudkit-web-services

在我通过URL将recordName传递到第二页的网站上工作。我看到recordName {data}的正确解析,然后尝试使用filterBy进行查询,如下所示:

        var query = { recordType: 'Events', 
            filterBy: [{
                fieldName: 'recordName',
                comparator: 'EQUALS',
                fieldValue: {value: [{data}]
                }
            }]
         };

         return publicDB.performQuery(query).then(function (response) {
            if(response.hasErrors) {
                console.error(response.errors[0]);
                return;
            }

            var records = response.records;
            var numberOfRecords = records.length;
            if (numberOfRecords === 0) {
                console.error('No matching items');
                return;
            }

            self.events(records);

此方法和将fieldName指定为recordName的其他尝试都会产生相同的错误消息:

    ckErrorCode:"NOT_FOUND"
    extensionErrorCode:undefined
    reason:"ObjectNotFoundException: no such field recordName"
    recordName:undefined
    redirectURL:undefined
    retryAfter:undefined
    serverErrorCode:"NOT_FOUND"
    subscriptionID:undefined
    uuid:"7ff93475-a22c-4ae2-859f-4a219e0253b1"
    zoneID:undefined
    message:"ObjectNotFoundException: no such field recordName"

这看起来很奇怪,但也许它很明显很容易解决。

任何建议都表示赞赏。

1 个答案:

答案 0 :(得分:3)

recordName是一个系统字段,下面是您应该如何查询这些字段:

var query = {
    recordType: 'Events',
    filterBy: [{
        comparator: 'EQUALS',
        systemFieldName: 'recordName',
        fieldValue: {
            value: 'the-name-of-the-record'
        }
    }]
}

由于已知错误,您必须在recordName附近添加其他包装:

var query = {
    recordType: 'Events,
    filterBy: [{
        comparator: 'EQUALS',
        systemFieldName: 'recordName',
        fieldValue: {
            value: {
                recordName: 'the-name-of-the-record'
            }
        }
    }]
}