gpt4 book ai didi

java - 解析 "no results found for query (code 101)"。无法获取对象 ID

转载 作者:太空狗 更新时间:2023-10-29 14:01:37 29 4
gpt4 key购买 nike

我已经在我的桌面上安装了示例解析服务器 ( https://github.com/ParsePlatform/parse-server-example ) 并制作了一个简单的应用程序来测试它。

我的应用程序将一个对象保存到服务器,获取该对象并将 mTextView 的值设置为我的对象的值。

问题是,当我尝试使用此代码从服务器获取数据时,它起作用了:

    query.getInBackground("5K7N8a8Dmd", new GetCallback<ParseObject>() ...

(通过curl获取对象id)

但是当我尝试这样做时(不使用 curl 获取对象 ID):

            gameScore.saveInBackground(new SaveCallback() {
public void done(ParseException e) {
if (e == null) {
objectId = gameScore.getObjectId();
} else {
Log.e("saveInBackground", getErrorMessage(e));
}
}
});

...

query.getInBackground(objectId, new GetCallback<ParseObject>() ...

它不起作用。

日志:

E/getInBackground﹕ no results found for query - code: 101

主 Activity .java

    public class MainActivity extends Activity {

public TextView mTextView;
public String objectId;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mTextView = (TextView) findViewById(R.id.text_view);

Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
.applicationId(Constants.APP_ID)
.server(Constants.SERVER_URL)
.build()
);

final ParseObject gameScore = new ParseObject("Foo1234");
gameScore.put("score", 5000);
gameScore.saveInBackground(new SaveCallback() {
public void done(ParseException e) {
if (e == null) {
objectId = gameScore.getObjectId();
} else {
Log.e("saveInBackground", getErrorMessage(e));
}
}
});

ParseQuery<ParseObject> query = ParseQuery.getQuery("Foo1234");
query.getInBackground(objectId, new GetCallback<ParseObject>() {
public void done(ParseObject object, ParseException e) {
if (e == null) {
mTextView.setText(Integer.toString(gameScore.getInt("score")));
} else {
Log.e("getInBackground", getErrorMessage(e));
}
}
});
}

public String getErrorMessage(ParseException e) {
return e.getMessage() + " - code: " + e.getCode();
}
}

常量.java

    public class Constants {
public static String SERVER_URL = "http://192.168.1.14:1337/parse/";
public static String APP_ID = "myAppId";
}

提前致谢。

最佳答案

试试这个

ParseQuery<ParseObject> query = ParseQuery.getQuery("_Foo1234");
query.whereEqualTo("objectId","wfBB0gpCkP");
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> objects, ParseException e) {
if (e == null) {
// row of Object Id "wfBB0gpCkP"
} else {
// error
}
}
});

也改变

ParseQuery<ParseObject> query = ParseQuery.getQuery("Foo1234");

ParseQuery<ParseObject> query = ParseQuery.getQuery("_Foo1234"); 

看看这是否有效。

关于java - 解析 "no results found for query (code 101)"。无法获取对象 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35232402/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com