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