我有一个像这样的表结构试图获取所有相关表的多个数据 -
我有类别列表( ProfileCateGory对象),并且在配置文件日期的每个类别列表( ProfileData对象)中都有视图计数( ProfileViewCount对象< /强>)
我是Parse.com的新用户,我试过这样 -
ParseQuery<ParseObject> query = ParseQuery.getQuery("ProfileData");
query.whereEqualTo("profileName", "Profile");
try {
for (int i = 0; i < query.count(); i++) {
query.getFirstInBackground(new GetCallback<ParseObject>() {
public void done(ParseObject object, ParseException e) {
if (object == null) {
Log.d("ProfileData", "Error: " + e.getMessage());
} else {
Log.d("TAG", "Name: " + object.get("profileName").toString());
}
}
});
}
} catch (Throwable t) {
}
我只从ProfileData获得一个数据。
答案 0 :(得分:0)
您可以使用relational-queries
为此,您必须在profileCode
ProfileViewCounts
作为指针类型
ParseQuery<ParseObject> innerQuery = ParseQuery.getQuery("ProfileData");
innerQuery.whereEqualTo("profileName", "Profile");
ParseQuery<ParseObject> query =ParseQuery.getQuery("ProfileViewCounts");
query.whereMatchesQuery("profileCode", innerQuery);
query.getFirstInBackground(new GetCallback<ParseObject>() {
@Override
public void done(ParseObject objProfileViewCounts, ParseException e) {
// TODO Auto-generated method stub
}
});
答案 1 :(得分:0)
getFirstInBackground()是调用并返回一个项目。
要获得一个或多个对象,您需要这样做:
//profile or id of user , you have to pass as a parameter
ParseQuery<ParseObject> query = ParseQuery.getQuery("ProfileData");
query.whereEqualTo("profileName", Profile);
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> objects, ParseException e) {
if (e == null) {
for (int inP = 0; inP < objects.size(); inP++) {
String profileName = objects.get(inP).getString("profileName");
}
} else {
}
}