-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial version of command: oa:data:soql:sel
- Loading branch information
1 parent
130dfe6
commit 6ac3a15
Showing
11 changed files
with
297 additions
and
44 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
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,3 @@ | ||
{ | ||
"typescript.tsdk": "node_modules\\typescript\\lib" | ||
} |
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
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
{ | ||
"commandDescription": "generate query for all fields from SObject (SEL * FROM SObject)", | ||
"fromFlagDescription": "SObject to generate query for", | ||
"whereFlagDescription": "Add WHERE clause to Your query" | ||
} |
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
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
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,54 @@ | ||
import { core, flags, SfdxCommand } from '@salesforce/command'; | ||
import { AnyJson } from '@salesforce/ts-types'; | ||
import ncp = require('copy-paste'); | ||
|
||
core.Messages.importMessagesDirectory(__dirname); | ||
const messages = core.Messages.loadMessages('osiecki-sfdx-plugins', 'sel'); | ||
|
||
export default class Sel extends SfdxCommand { | ||
|
||
public static description = messages.getMessage('commandDescription'); | ||
public static examples = [ | ||
`sfdx oa:data:soql:sel -f ApexLog | ||
Your query was succesfully copied to clipboard: | ||
SELECT Id, LogUserId, LogLength, LastModifiedDate, Request, Operation, Application, Status, DurationMilliseconds, | ||
SystemModstamp, StartTime, Location FROM ApexLog | ||
`, | ||
`sfdx oa:data:soql:sel -f ApexLog --json | ||
{ | ||
"status": 0, | ||
"result": { | ||
"query": "SELECT Id, LogUserId, LogLength, LastModifiedDate, Request, Operation, Application, Status, | ||
DurationMilliseconds, SystemModstamp, StartTime, Location FROM ApexLog" | ||
} | ||
} | ||
`, | ||
`sfdx oa:data:soql:sel -f ApexLog -w "LogLength > 100" | ||
Your query was succesfully copied to clipboard: | ||
SELECT Id, LogUserId, LogLength, LastModifiedDate, Request, Operation, Application, Status, DurationMilliseconds, | ||
SystemModstamp, StartTime, Location FROM ApexLog WHERE Where LogLength > 100 | ||
` | ||
]; | ||
|
||
protected static requiresUsername = true; | ||
protected static flagsConfig = { | ||
from: flags.string({ char: 'f', required: true, description: messages.getMessage('fromFlagDescription') }), | ||
where: flags.string({ char: 'w', description: messages.getMessage('whereFlagDescription') }) | ||
}; | ||
|
||
public async run(): Promise<AnyJson> { | ||
let query: string = ''; | ||
const conn = this.org.getConnection(); | ||
await conn.sobject(this.flags.from).find().where(this.flags.where) | ||
.toSOQL((err, res) => { | ||
if (err) { | ||
this.ux.log(err.message); | ||
} else { | ||
query += res; | ||
ncp.copy(query); | ||
this.ux.log('Your query was succesfully copied to clipbzoard:\n' + query); | ||
} | ||
}); | ||
return { query }; | ||
} | ||
} |
Oops, something went wrong.