Last active
April 7, 2018 04:45
-
-
Save ChuckJonas/dd1ebece206b135929ec39e781423af3 to your computer and use it in GitHub Desktop.
BASS ts-force example
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
let accId = 'blah'; | |
let accounts = await Account.retrieve( | |
`SELECT ${generateSelect(Object.values(Account.FIELDS))}, | |
( | |
SELECT Owner.Id, Owner.Name | |
FROM ${Account.FIELDS.contacts.apiName} | |
) | |
FROM Account | |
WHERE Id = '${accId}'` | |
); | |
accounts.forEach(acc => { | |
acc.contacts.forEach(contact => { | |
if(contact.owner.name === 'the dude'){ | |
contact.ownerId = acc.ownerId; | |
await contact.update(true); //should use CompositeCollection to bulkify this instead | |
} | |
}); | |
}); | |
let bulk = new CompositeCollection(); | |
bulk.delete(accounts); //I didn't like those accounts anyways ;0 | |
let newAcc = new Account({name: 'abc', otherField: 123}); | |
await newAccount.insert(); //this one is much better | |
console.log(newAccount.id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment