根据ID更新分析数据库中的行
Updating a row in Parse database against an ID
我正在尝试使用java脚本针对特定的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);
}
});
有什么想法吗?
解决了它!万一有人好奇,下面是修改后的代码:
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);
}
});
相关文章:
- 在不重构Mongo数据库的情况下,更新嵌入数组中的具有给定ID的对象
- 如何设置从数据库到php会话的id点击链接
- 单击图像时从数据库加载选项id
- 我想单击一个
- 并获取 id 以通过 POST 将其插入数据库,可以吗?
- 如何将下拉列表中检索到的值的id从数据库发送到php文件
- 如何在 PHP 和数据库中的 OpenTracker() 中传递动态 ID
- 数据表 - 通过单击事件获取当前行的数据库 ID
- 将 PHP 数据库中的 ID 保存为变量
- 根据按 id 搜索将数据库的值设置为文本框
- 将数据库 ID 排序到垂直时间轴中
- 从数据库中检索的选中复选框的数据库中获取ID
- 当 Javascript 中的 POST ID 元素插入 PDO 时,数据库中没有结果
- 如何通过Firebase数据库中的AngularJS在点击时获取数组元素的唯一ID
- angularjs选择框基于数据库id的默认选择
- 创建Raphael Path与数据库ID之间的关系
- 如何传递数据库ID到Rails URL路径
- 我如何得到mysql数据库id随机回声
- 如何从HTML/Javascript隐藏数据库ID
- Jquery数据表服务器端处理按数据库id选择行
- 哪里是在客户端上放置数据库ID的最佳位置