objectId,在back4app上解析

时间:2018-02-01 22:27:36

标签: java android parse-platform

代码如下:

在数据库中查找用户:

 private void updataUserRated() {
      final ParseQuery<ParseObject> userObject = ParseQuery.getQuery("User");
   userObject.whereEqualTo("objectId", userId);
   userObject.findInBackground(new FindCallback<ParseObject>() {
       @Override
       public void done(List<ParseObject> objects, ParseException e) {

如何从用户中找到一个objectid来保存带解析的ratingBar的值?

               if (e == null) {//sucess
               userObject.getInBackground("#########", new GetCallback<ParseObject>() {
               @Override
               public void done(ParseObject object, ParseException e) {
                   if (e == null){//sucess
                       object.put("rated", ratingBar.getRating());
                       object.saveInBackground(new SaveCallback() {
                           @Override
                           public void done(ParseException e) {
                               Toast.makeText(FeedUserActivity.this, "Sucesso ao enviar", Toast.LENGTH_LONG).show();
                           }
                       });
                   }else {
                       Toast.makeText(FeedUserActivity.this, "Error 1" + e.getMessage(), Toast.LENGTH_LONG).show();
                   }
               }
           });
           } else {
               Toast.makeText(FeedUserActivity.this, "Error 2" + e.getMessage(), Toast.LENGTH_LONG).show();
           }
       }
   });

}

1 个答案:

答案 0 :(得分:0)

在JavaScript中,您只需使用 .id 即可访问任何解析对象的 objectId ,因此,如果您有解析对象的userObject,那么您可以像这样得到objectId:

const objectId = userObject.id;