Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Knex.js dialect for building and executing Salesforce Queries (SOQL)
npm install knex-soql
const client = require('knex-soql');
const knex = require('knex')({
client,
connection: {
loginUrl: 'https://test.salesforce.com',
login: 'example@mail.com',
password: 'supersecret'
}
});
const contacts = await knex('Contact')
.select(['Id', 'Name'])
.where({ Name: 'example' })
.orderBy('CreatedBy')
.limit(10);
All queries to Salesforce are performed using jsforce and all the connection properties passed down to jsforce.Connection constructor:
const client = require('knex-soql');
const knex = require('knex')({
client,
connection: {
oauth2: {
clientId: '<your Salesforce OAuth2 client ID is here>',
clientSecret: '<your Salesforce OAuth2 client secret is here>',
redirectUri: '<your Salesforce OAuth2 redirect URI is here>'
},
instanceUrl: '<your Salesforce server URL (e.g. https://na1.salesforce.com) is here>',
accessToken: '<your Salesforrce OAuth2 access token is here>',
refreshToken: '<your Salesforce OAuth2 refresh token is here>'
}
});
Or you can even provide jsforce.Connection instance configured by yourself to knex along with knex-soql client:
const client = require('knex-soql');
const jsforce = require('jsforce');
const initKnex = require('knex');
const execute = async () => {
const connection = new jsforce.Connection();
await connection.login('example@mail.com', 'supersecret');
const knex = initKnex({ client, connection });
const contacts = await knex('Contact').select(['Id', 'Name']);
};
execute();
You can use knex-soql to build SOQL queries without execution:
const client = require('knex-soql');
const knex = require('knex')({ client });
const subquery = knex('Account.Contacts')
.select(['Contact.Id', 'Contact.Name'])
.orderBy('LastModifiedDate', 'desc')
.limit(3);
const query = knex('Account')
.select(['Id', 'Name', subquery])
.where({ Id: '1337' });
console.log(query.toString());
/*
select Id, Name, (
select Contact.Id, Contact.Name
from Account.Contacts
order by LastModifiedDate desc
limit 3
)
from Account
where Id = '1337'
*/
Copyright Yevhenii Baraniuk, 2017
FAQs
Knex.js dialect for building and executing Salesforce Queries (SOQL)
The npm package knex-soql receives a total of 138 weekly downloads. As such, knex-soql popularity was classified as not popular.
We found that knex-soql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.