Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
subtract-query-filter
Advanced tools
You need to fetch a lot of data from a remote server (with a filter that is defined on client-side and executed on server-side).
You want to fetch additional data of the same type, but you do not want to load documents a second time.
You could now include something like { _id: { $nin: [ ... a lot of ids ] } }
to your filter.
This package offers a different approach: You just have to subtract the previously used filter from your new one.
You implemented a calender with a day- and a month-view. There are a lot of events each there (therefore its expensive to exclude already fetched ids from new queries).
The user navigates through the app:
Time span fetched | Internal query | Query to server |
---|---|---|
02.01. | {date: {$in: [02.01.]} | {date: {$in: [02.01.]} |
01.01. - 07.01. | {date: {$gte: '01.01.', $lte: '07.01.' | {date: {$gte: '01.01.', $lte: '07.01.', $nin: [02.01.] |
04.01. - 10.01. | {date: {$gte: '04.01.', $lte: '10.01.' | {date: {$gt: '07.01.', $lte: '10.01.'} |
All of this does only make since if you need to fetch a lot of data or really must reduce the transferred data to a minimum.
If you don't, you might want to just fetch that data a second time.
export type FilterConstraint = {
$in?: any[];
$nin?: any[];
$lt?: any;
$gt?: any;
$lte?: any;
$gte?: any;
}
export interface Filter {
[key: string]: FilterConstraint;
}
The operations are restricted to the above.
{ $eq: VAL }
must be expressed as { $in: [ VAL ] }
.
{ $ne: VAL }
must be expressed as { $nin: [ VAL ] }
.
So far, it is not possible to use query operators like $and, $or, $all etc...
FAQs
Subtracting filters analytically.
We found that subtract-query-filter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.