Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
I wanted an easy way to build elasticsearch queries without having to writing lots and lots of code just for the structure of the query. For that reason I created ESQ, a very simple but powerful tool that will do all of the object creation for you.
npm install esq
or bower intall esq
Example
var ESQ = require('esq');
var esq = new ESQ();
esq.query('bool', ['must'], { match: { user: 'kimchy' } });
esq.query('bool', 'minimum_should_match', 1);
var query = esq.getQuery();
Generates
{
"bool": {
"must": [
{
"match": {
"user": "kimchy"
}
}
],
"minimum_should_match": 1
}
}
<script src="esq.js"></script>
<script>
var esq = new ESQ();
esq.query('bool', ['must'], { match: { user: 'kimchy' } });
var query = esq.getQuery();
</script>
This will return the query at the current stage.
Example
esq.query('bool', ['must'], { match: { foo: 'bar' } });
var query = esq.getQuery();
Generates
{
"bool": {
"must": [
{
"match": {
"foo": "bar"
}
}
]
}
}
You can pass this function as many strings as you want and you'll receive a nested object with the arguments as keys. The final argument should always be the object you want to assign to the second to last argument. This function will always return the query at its current state.
Example
esq.query('filtered', 'query', { match: { foo: 'bar' } });
Generates
{
"filtered": {
"query": {
"match": {
"foo": "bar"
}
}
}
}
The function also allows you to pass in an argument as an array (e.g. ['must']
). This tells the function that you want that key to be an array and so it'll push the following arguments into the array.
Example
esq.query('filtered', 'query', 'bool', ['must'], { match: { 'foo': 'bar' } });
Generates
{
"filtered": {
"query": {
"bool": {
"must": [
{
"match": {
"foo": "bar"
}
}
]
}
}
}
}
This module is fully tested, run the tests using mocha
.
FAQs
Easily build elasticsearch queries
The npm package esq receives a total of 1,068 weekly downloads. As such, esq popularity was classified as popular.
We found that esq 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.