-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create at_delete_orphaned_subscriptions.js
- Loading branch information
1 parent
15afb21
commit e763008
Showing
1 changed file
with
11 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Delete all subscriptions no longer attached to a | ||
// subscriber, or where the value is zero | ||
let subscriptionsTable = base.getTable('Subscriptions'); | ||
let subscriptionsView = subscriptionsTable.getView('Grid view'); | ||
|
||
let subscriptionsResults = await subscriptionsView.selectRecordsAsync({fields: ['Subscribers','Monthly Rate','Number of Shares']}); | ||
for(let shareRecord of subscriptionsResults.records){ | ||
if(shareRecord.getCellValueAsString('Subscribers').length == 0 || shareRecord.getCellValue('Number of Shares') == 0){ | ||
await subscriptionsTable.deleteRecordAsync(shareRecord.id); | ||
} | ||
} |