我正在尝试使用java-script更新解析数据库中针对特定userId
(Parse数据库中的表中的列)的行。但问题是,当下面的代码运行时,正在创建一个新行。我无法弄清楚我做错了什么。
var profileQuery = new Parse.Query(Profile);
profileQuery.equalTo("userId","objectId")
profileQuery.first({
success: function(object)
{
profile.set("profilePic", theFile);
profile.save({success: function()
{
console.log("Profile Picture saved successfully !");
profileQuery.find({
success: function(results)
{
var output ="";
for (var i in results)
{
if(results[i].get("profilePic"))
{
var file = results[i].get("profilePic");
var url = file.url();
console.log("Image URL is:"+url);
console.log(" Value of i: "+i);
document.getElementById("profileDp").src=url;
}
}
}
});
}, error: function(file, error){
console.log("Profile pic upload error !" + error.message);
}
});
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
任何想法?
答案 0 :(得分:0)
解决了!以防万一有人好奇,下面是修改后的代码:
var profileQuery = new Parse.Query(Profile);
profileQuery.equalTo("userId",objectId);
profileQuery.first({
success: function(object)
{
object.set("profilePic", theFile);
object.save({success: function()
{
console.log("Profile Picture saved successfully !");
profileQuery.find({
success: function(results)
{
var output ="";
for (var i in results)
{
if(results[i].get("profilePic"))
{
var file = results[i].get("profilePic");
var url = file.url();
console.log("Image URL is:"+url);
console.log(" Value of i: "+i);
document.getElementById("profileDp").src=url;
}
}
}
});
}, error: function(file, error){
console.log("Profile pic upload error !" + error.message);
}
});
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});