-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.ts
29 lines (23 loc) · 1.01 KB
/
delete.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { flags, SfdxCommand } from '@salesforce/command';
import { singleRecordQuery } from '@mshanemc/plugin-helpers/dist/queries';
export default class PushTopicDelete extends SfdxCommand {
public static description = 'Delete a push topic';
public static aliases = ['shane:streaming:pushtopic:delete'];
public static examples = [`sfdx streaming:pushtopic:delete -n myTopic`];
protected static flagsConfig = {
name: flags.string({
char: 'n',
description: 'name for the push topic',
required: true
})
};
protected static requiresUsername = true;
public async run(): Promise<any> {
const conn = this.org.getConnection();
// verify that the topic doesn't already exist
const existing = await singleRecordQuery({ conn, query: `Select id from PushTopic where Name='${this.flags.name}'` });
const output = await conn.sobject('PushTopic').destroy(existing.Id);
this.ux.log(`Deleted`);
return output;
}
}