Installations
npm install waterline-criteria-test
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
8.1.3
NPM Version
5.2.0
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
frank198
Download Statistics
Total Downloads
1,052
Last Day
2
Last Week
3
Last Month
11
Last Year
63
GitHub Statistics
121 Commits
1 Watching
4 Branches
1 Contributors
Bundle Size
158.00 kB
Minified
38.32 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.0.2
Package Id
waterline-criteria-test@2.0.2
Size
15.52 kB
NPM Version
5.2.0
Node Version
8.1.3
Total Downloads
Cumulative downloads
Total Downloads
1,052
Last day
0%
2
Compared to previous day
Last week
-25%
3
Compared to previous week
Last month
175%
11
Compared to previous month
Last year
-42.7%
63
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
21
Dev Dependencies
1
waterline-criteria
Utilities for working with Waterline criterias, especially for applying them to in-memory datasets.
This module was designed for adapters which communicate with key/value stores such as
sails-disk
, sails-memory, and sails-redis (i.e. they already implement thesemantic
interface, but need to implement thequeryable
interface).
Installation
1$ npm install waterline-criteria --save
Filtering an array
Filter an array of dictionaries.
1var WLCriteria = require('waterline-criteria'); 2 3var results = WLCriteria(dataset, criteria);
Argument | Type | Details | |
---|---|---|---|
1 | dataset | ((array)) | An array of dictionaries to filter/sort. |
2 | criteria | ((dictionary)) | A Waterline criteria dictionary. See Concepts > Models & ORM > Query Language for more information. |
Returns a filtered result set.
Example
1var WLCriteria = require('waterline-criteria'); 2 3var SOME_DATASET = [ 4 { 5 id: 1, 6 name: 'Lyra' 7 }, 8 { 9 id: 2, 10 name 'larry' 11 } 12]; 13 14// Filter dataset. 15var results = WLCriteria(SOME_DATASET, { 16 where: { 17 name: { contains: 'lyr' } 18 } 19}).results; 20 21// x ==> [{name: 'Lyra', id: 1}]
.validateWhereClause()
Check a where
clause for obviously unsupported usage.
This does not do any schema-aware validation-- its job is merely to check for structural issues, and to provide a better experience when integrating from userland code.
1var WLCriteria = require('waterline-criteria'); 2 3try { 4 WLCriteria.validateWhereClause(where); 5} catch (e) { 6 switch (e.code) { 7 case 'E_WHERE_CLAUSE_UNPARSEABLE': 8 // ... 9 break; 10 default: throw e; 11 } 12} 13 14// ...
Argument | Type | Details | |
---|---|---|---|
1 | where | ((dictionary)) | A hypothetically well-formed where clause from a Waterline criteria. |
If
where
clause cannot be parsed, throws an Error with a code property of'E_WHERE_CLAUSE_UNPARSEABLE'
.
.validateSortClause()
Check a sort
clause for obviously unsupported usage.
This does not do any schema-aware validation-- its job is merely to check for structural issues, and to provide a better experience when integrating from userland code.
1var WLCriteria = require('waterline-criteria'); 2 3try { 4 WLCriteria.validateSortClause(sort); 5} catch (e) { 6 switch (e.code) { 7 case 'E_SORT_CLAUSE_UNPARSEABLE': 8 // ... 9 break; 10 default: throw e; 11 } 12} 13 14// ...
Argument | Type | Details | |
---|---|---|---|
1 | sort | ((dictionary)) or ((string)) | A hypothetically well-formed sort clause from a Waterline criteria. |
If
sort
clause cannot be parsed, throws an Error with a code property of'E_SORT_CLAUSE_UNPARSEABLE'
.
Bugs  ![NPM version](https://badge.fury.io/js/waterline-criteria.svg)
To report a bug, click here.
This is a built-in module in the Sails framework and the
sails-disk
adapter. It is installed automatically when you runnpm install sails
.
Version notes
The master branch of this repository holds waterline-criteria
used in Sails versions 0.10.0 and up. If you're looking for the version for the v0.9.x releases of Sails, the source is located here.
Contributing  ![Build Status](https://travis-ci.org/balderdashy/waterline-criteria.svg?branch=master)
Please observe the guidelines and conventions laid out in the Sails project contribution guide when opening issues or submitting pull requests.
License
The Sails framework is free and open-source under the MIT License.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.6
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More