如何检索Quickblox自定义对象的相关记录?(How to retrieve related r

2019-10-19 09:08发布

我知道如何创建关系:

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?

Answer 1:

你应该做这一个单独的请求:

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

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


文章来源: How to retrieve related records on Quickblox custom objects?