Azure的移动服务计划删除表 [英] Azure Mobile Services Scheduled Delete From Table
问题描述
谁能帮我我该怎么去写一个脚本,从计划任务删除移动服务表中的记录?我要天天来清除领导委员会和计划任务,似乎去这样做的最佳方式,但文档似乎有点粗略。
Can anyone help me with how I go about writing a script to delete the records from a Mobile Services table from a scheduled task? I want to clear the leader board every day and a scheduled task seems the best way to go about doing this but the documentation seems a little sketchy.
我创建的时间表,但不知道怎么修改脚本以删除表中的所有行。
I have created the schedule but don't know how the modify the script to delete all the rows in the table.
我看这里和这里,但他们并没有真正摆脱任何光线。
I looked here and here but they haven't really shed any light.
非常感谢,
贾森。
推荐答案
从表中删除记录的最简单方法是使用 MSSQL
对象,并发送删除
数据库查询,如下图所示。像往常一样,任何时候你发送一个删除没有任何过滤器,运行它的很仔细
The easiest way to delete the records from a table is to use the mssql
object, and send a DELETE
query to the database, as shown below. As usual, anytime you're sending a 'DELETE' without any filter, run it very carefully.
function MyScheduledTask() {
var sql = 'DELETE from YourTableName'; // Run with care!!!
mssql.query(sql, {
success: function(results) {
console.log('Success: ', results);
}, error: function(err) {
console.log('Error: ', err);
}
});
}
这篇关于Azure的移动服务计划删除表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!