我正在创建一个引用自己的解析类,而且在使用javascript sdk或其他api时,我似乎无法检索父级。有谁知道这是否可能使用解析?我应该以不同的方式构建我的数据吗?我的课程的一个例子如下。我不想为子类别设置单独的类,因为它们与顶级类别的结构相同。
ProductCategory
name (string)
description (string)
parentCategory (pointer to ProductCategory)
这就是我尝试使用javascript SDK提取数据的方法:
var ProductCategory = parse.Object.extend("ProductCategory");
var query = new parse.Query(ProductCategory);
query.include('parentCategory');
query.find()
这里是尝试使用REST api(注意没有返回parentCategory):
curl --request GET --url 'https://api.parse.com/1/classes/ProductCategory?include=parentCategory' --header 'content-type: application/json' --header 'x-parse-application-id: blah' --header 'x-parse-rest-api-key: blah'
{
"results": [
{
"createdAt": "2015-05-29T07:27:05.745Z",
"name": "Category 1",
"objectId": "skrxpy2ogU",
"updatedAt": "2015-07-20T03:39:45.567Z"
},
{
"createdAt": "2015-05-29T07:27:12.603Z",
"name": "Category 1.1",
"objectId": "G37aLflfgQ",
"updatedAt": "2015-05-29T07:28:06.764Z"
}
]
}