我在Azure的移动服务中的表格中有一个插入代码,我想知道是否有更好的方法来获取当前表格的插入脚本。
今天我的桌子的代码" ClientTest1"看起来像这样:
function insert(item, user, request) {
var payload = {
data: {
msg: "Nivel: " + item.Nivel
}
};
request.execute({
success: function() {
// If the insert succeeds, send a notification.
push.gcm.send("ClientTest1", payload, {
success: function(pushResponse) {
console.log("Sent push:", pushResponse, payload);
request.respond();
},
error: function (pushResponse) {
console.log("Error Sending push:", pushResponse);
request.respond(500, { error: pushResponse });
}
});
},
error: function(err) {
console.log("request.execute error", err)
request.respond();
}
});
}
我想要这样的代码:
function insert(item, user, request) {
var payload = {
data: {
msg: "Nivel: " + item.Nivel
}
};
request.execute({
success: function() {
// If the insert succeeds, send a notification.
push.gcm.send(tables.current.name, payload, {
success: function(pushResponse) {
console.log("Sent push:", pushResponse, payload);
request.respond();
},
error: function (pushResponse) {
console.log("Error Sending push:", pushResponse);
request.respond(500, { error: pushResponse });
}
});
},
error: function(err) {
console.log("request.execute error", err)
request.respond();
}
});
}
我想在"标记"中不需要硬编码表的每个名称。推送的参数。
有谁知道更好的方法吗?谢谢
答案 0 :(得分:2)
您可以使用current
全局对象的tables
属性,这将返回当前表。所以你可以用它来表名:
var tableName = tables.current.getTableName();