SalesforceLiteConnection
it is a promise based library that wraps Salesforce CRUD rest api. it is meant to be used in apps that require a one time connection to Salesforce. SalesforceLiteConnection uses the Username-Password OAuth Authentication Flow as.
Requirements
- A connected app
- Salesforce user credentials
Caveats
- It does not provide a refresh token.
- SalesforceConnection instance can only be created through SalesforceLiteConnection.createConnection.
Installation
npm install salesforceLiteConnection
API
SalesforceLiteConnection
createConnection(authInfo)
Creates a connection to a salesforce org specify the params
Parameters
- authInfo
object
specifies the information about where to connect
Return
Promise (it resolves into an instance of SalesforceConnection);
Example
const SalesforceLiteConnection = ; SalesforceLiteConnection;
SalesforceConnection
query(soql)
Executes the given soql string.
Parameters
- soql
string
soql query to execute
Return
Promise (for more info the response body see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm)
Example
const createConnection = ; ;
insert(sobjectApiName, fieldsToSet)
Inserts a record.
Parameters
- sobjectApiName
string
sobject api name - fieldsToSet
object
fields to set
Return
Promise (for more info the response body see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_create.htm)
Example
const createConnection = ; ;
update(sobjectApiName, recordId, fieldsToUpdate)
Updates a record.
Parameters
- sobjectApiName
string
sobject api name - recordId
string
record to update - fieldsToSet
object
fields to update
Return
Promise (for more info the response body see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_update_fields.htm)
Example
const createConnection = ; ;
delete(sobjectApiName, recordId)
Deletes a record.
Parameters
- sobjectApiName
string
sobject api name - recordId
string
record to update
Return
Promise (for more info the response body see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_delete_record.htm)
Example
const createConnection = ; ;
bulkInsert(sobjectApiName, records, allOrNone)
Inserts a collection of records (up to 200 records).
Parameters
- sobjectApiName
string
sobject api name - records
array
Collection of records to insert - allOrNone
boolean
Indicates whether to roll back the entire request when the creation of any object fails (default true)
Return
Promise (for more info the response body see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_sobjects_collections_create.htm)
Example
const createConnection = ; ;
bulkUpdate(sobjectApiName, records, allOrNone)
Updates a collection of records (up to 200 records).
Parameters
- sobjectApiName
string
sobject api name - records
array
Collection of records to update (each record must have the Id field filled) - allOrNone
boolean
Indicates whether to roll back the entire request when the update of any object fails (default true)
Return
Promise (for more info the response body see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_sobjects_collections_update.htm)
Example
const createConnection = ; ;
bulkDelete(sobjectApiName, recordIds, allOrNone)
Updates a collection of records (up to 200 records).
Parameters
- sobjectApiName
string
sobject api name - recordIds
array
Collection of record to delete - allOrNone
boolean
Indicates whether to roll back the entire request when the delete of any object fails (default true)
Return
Promise (for more info the response body see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_sobjects_collections_delete.htm)
Example
const createConnection = ; ;
composite(compositeRequest, allOrNone)
Updates a collection of records (up to 200 records).
Parameters
- recordIds
array
Collection of subrequests to execute - allOrNone
boolean
Indicates whether to roll back the entire request when an error occurs while processing a subrequest (default true).
Return
Promise (for more info the response body see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_composite.htm)
Example
const createConnection = ; ;