PurgePropertyHistory
描述
更新已記錄的內容時,資料會寫入至與物件相關聯的值串流。您可以使用 PurgePropertyHistory 服務,從一個已記錄內容中清除指定時間範圍內的歷史資料。
將清除呼叫服務之物件的內容記錄,但不會清除其他物件的內容記錄。如果您要清除多個物件的歷史資料,則必須針對每個物件呼叫服務。
依預設,此清除會以非同步方式執行。
輸入
參數名稱
描述
基礎類型
propertyName
應清除其歷史資料之內容的名稱。
STRING
startDate
應清除歷史資料的開始日期,包括指定日期。
DATETIME
endDate
應清除歷史資料的結束日期,包括指定日期。
DATETIME
immediate
若為 false,清除會以非同步方式執行。預設值為 false。如果設定為 true,清除將會同步執行。
BOOLEAN
輸出
無。
範例
在下列範例中,物件具有名為 propertyA-Logged 的已記錄內容,該內容已多次更新,且正在收集歷史資料。
可對輸入參數進行內置傳遞,如下所示:
// Purging historical data between the given start and end dates
Things["TestThing"].PurgePropertyHistory({
propertyName: 'propertyA-Logged' /* STRING */,
startDate: '2024-05-12T16:58:28.000Z' /* DATETIME */,
endDate: 'Date.now()' /* DATETIME */,
immediate: true /* BOOLEAN {"defaultValue":false} */
});
或者,您也可以建構資料負載。
// Params for purging historical data from the past year
var purgeHistoryParams = {
propertyName: 'propertyA-Logged' /* STRING */,
startDate: new Date(new Date().setFullYear(new Date().getFullYear() - 1)),
endDate: Date.now(),
immediate: true /* BOOLEAN */
};
Things["TestThing"].PurgePropertyHistory(purgeHistoryParams);
這是否有幫助?