1

我有一个库存表,我想使用材料名称更新数量。请提出更新查询。

final ParseQuery<ParseObject> query = ParseQuery.getQuery("Stock");
    query.whereEqualTo("material_name",materialname);
    query.getInBackground(materialname, new GetCallback<ParseObject>() {
        @Override
            public void done(ParseObject object, ParseException e) {
                if(e==null) {
                    String previous_quantity= object.getString("material_quantity");
                    Integer total=Integer.parseInt(previous_quantity)+Integer.parseInt(quantity_material);
                    object.put("material_quantity",total.toString());

                    object.saveInBackground(new SaveCallback() {
                        @Override
                        public void done(ParseException e) {

                        }
                    });
                }
                else
                {
                    Log.e("Error",e.getLocalizedMessage());
                    Toast.makeText(Addmaterial_activity.this,"Error"+e.getLocalizedMessage(),Toast.LENGTH_LONG).show();
                }
            }
        });
4

1 回答 1

1

在 Parse Server Docs,有一个在后台搜索的示例,如下面的代码:

ParseQuery<ParseObject> query = ParseQuery.getQuery("GameScore");
query.whereEqualTo("playerName", "Dan Stemkoski");
query.findInBackground(new FindCallback<ParseObject>() {
    public void done(List<ParseObject> scoreList, ParseException e) {
        if (e == null) {
            Log.d("score", "Retrieved " + scoreList.size() + " scores");
        } else {
            Log.d("score", "Error: " + e.getMessage());
        }
    }
});

您可以在下面的链接中查看更多信息:

http://docs.parseplatform.org/android/guide/#basic-queries

于 2018-04-26T14:18:21.063 回答