解析服务器查询 objectId
Parse Server Query objectId
我使用 Parse Server Javascript SDK 在我的 Web 应用程序中使用以下查询。控制台日志按预期为我提供了提取信息的显示,但显示 "undefined".
的 objectId 除外
var query = new Parse.Query("myClass");
query.include("product");
query.find({
success: function (results) {
$scope.items = [];
for (i = 0; i < results.length; i++) {
var p = results[i].get("product");
var item = {
id: results[i].get("objectId"),
barcode: p.get("barcode"),
productName: p.get("name"),
imageUrl: p.get("image"),
desiredStock: results[i].get("desiredStock"),
}
$scope.items[$scope.items.length] = item;
console.log(item);
}
$scope.$apply();
},
error: function (error) {
console.log("Query Error: " + error.message);
}
})
如何将 objectId 获取到 item.id?
我已经弄明白了。有问题的行:
id: results[i].get("objectId"),
适用于此命令:
id: results[i]._getId(),
你可以这样写:
results[i].id
这是使用 Parse JS SDK 获取 objectId 的最佳方式
我使用 Parse Server Javascript SDK 在我的 Web 应用程序中使用以下查询。控制台日志按预期为我提供了提取信息的显示,但显示 "undefined".
的 objectId 除外var query = new Parse.Query("myClass");
query.include("product");
query.find({
success: function (results) {
$scope.items = [];
for (i = 0; i < results.length; i++) {
var p = results[i].get("product");
var item = {
id: results[i].get("objectId"),
barcode: p.get("barcode"),
productName: p.get("name"),
imageUrl: p.get("image"),
desiredStock: results[i].get("desiredStock"),
}
$scope.items[$scope.items.length] = item;
console.log(item);
}
$scope.$apply();
},
error: function (error) {
console.log("Query Error: " + error.message);
}
})
如何将 objectId 获取到 item.id?
我已经弄明白了。有问题的行:
id: results[i].get("objectId"),
适用于此命令:
id: results[i]._getId(),
你可以这样写:
results[i].id
这是使用 Parse JS SDK 获取 objectId 的最佳方式