我有一个库存表,我想使用物料名称更新数量。请建议更新查询。
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();
}
}
});
答案 0 :(得分:1)
在Parse Server Docs中,有一个在Background中搜索的示例,如下面的代码:
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());
}
}
});
您可以在以下链接查看更多相关信息: