如何在Quickblox自定义对象上检索相关记录?

时间:2014-02-17 10:11:00

标签: android quickblox custom-object

我知道如何创建关系:

QBCustomObject customObject = new QBCustomObject("Comment"); // your Class name
customObject.put(fieldHealth, 99);
customObject.put("text", "The first film in the series was...");
customObject.setParentId("50aa4d8fefa357fa14000001");

QBCustomObjects.createObject(qbCustomObject, new QBCallbackImpl() {
@Override
public void onComplete(Result result) {
    if (result.isSuccess()) {
        QBCustomObjectResult qbCustomObjectResult = (QBCustomObjectResult) result;
        QBCustomObject qbCustomObject = qbCustomObjectResult.getCustomObject();
        Log.d("New record: ",newCustomObject.toString());
    } else {
        Log.e("Errors",result.getErrors().toString());
    }
}
});

但是,当我有父ID时如何检索?

1 个答案:

答案 0 :(得分:2)

您应该单独请求:

QBCustomObjectRequestBuilder requestBuilder = new QBCustomObjectRequestBuilder();
requestBuilder.eq("_parent_id", "50aa4d8fefa357fa14000001");

QBCustomObjects.getObjects(CLASS_NAME, requestBuilder, new QBCallbackImpl(){...