Skip to content

Commit 108cc17

Browse files
authored
publish: v1.3.1
* enhance: readme.md documentation * change: version number from 1.3.0 to 1.3.1
1 parent f0fbfe1 commit 108cc17

File tree

2 files changed

+53
-7
lines changed

2 files changed

+53
-7
lines changed

README.md

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ $ npm install rsql-query-builder
1313
```
1414

1515
## Using the RSQL Builder
16+
1617
```typescript
1718
/* Long Version */
1819
const builder = new RSQLBuilder().equal('name', 'Filip').and().greaterThan('age', 30);
@@ -25,10 +26,55 @@ console.log(new RSQLBuilder().equal('name', 'Filip').and().greaterThan('age', 30
2526
// Output: name=="Filip";age=gt=30
2627
```
2728

28-
## Extending the RSQL Builder
29+
## RSQL Builder Methods
30+
31+
The `RSQLBuilder` class provides many methods to build the desired RSQL string.
32+
33+
### Initialization
34+
35+
constructor()
36+
37+
### Comparisons Operators (Defining Conditions)
38+
39+
`equal(selector, value)` - Appends a condition `selector == value`.
40+
`notEqual(selector, value)` - Appends a condition `selector != value`.
41+
`lessThan(selector, value)` - Appends a condition `selector =lt= value`.
42+
`lessThanOrEqual(selector, value)` - Appends a condition `selector =le= value`.
43+
`greaterThan(selector, value)` - Appends a condition `selector =gr= value`.
44+
`greaterThanOrEqual(selector, value)` - Appends a condition `selector =ge= value`.
45+
`in(selector, values)` - Appends a condition `selector =in= (values)`.
46+
`notIn(selector, value)` - Appends a condition `selector =out= (values)`.
47+
48+
### Expression Grouping (Organizing Conditions)
49+
50+
`group(builder)` - Wraps the conditions from another RSQLBuilder instance in parentheses for grouping.
51+
52+
### Logical Operators (Combining Conditions)
53+
54+
`and()` – Appends the logical **AND** operator `;`.
55+
`or()` - Appends a logical **OR** operator `,`.
56+
57+
### RSQL Builder Composition (Combining Multiple RSQL Queries)
58+
59+
`concat(builder)` – Appends all expressions from another RSQLBuilder instance to the current instance.
60+
`merge(builders)` – Merges multiple RSQLBuilder instances into grouped conditions.
61+
62+
### RSQL String Management (Finalizing the Query)
63+
64+
`toString()` - Returns the generated RSQL query string.
65+
`isEmpty()` – Returns true if the RSQLBuilder instance has no expressions; otherwise, returns false.
66+
`reset()` – Clears all expressions, resetting the RSQLBuilder instance.
67+
68+
### Static Utilities
69+
70+
`merge(builders)` – Creates a new RSQLBuilder instance and merges multiple RSQLBuilder instances into grouped conditions.
71+
72+
## Extending the RSQL Query Builder
73+
2974
You can extend the RSQL Builder to customize it for your needs.
3075

3176
This is a sample extension:
77+
3278
```typescript
3379
import RSQLBuilderBase, { RSQLBuilderOptions } from './RSQLBuilderBase';
3480

@@ -52,21 +98,21 @@ class RSQLBuilderSample<TSelector extends string = string> extends RSQLBuilderBa
5298
}
5399

54100
/** Add a like comparison to the query.
55-
*
101+
*
56102
* @param selector - The field name
57103
* @param value - The value to compare
58-
*
104+
*
59105
* @returns The builder instance
60106
*/
61107
like(selector: TSelector, value: string | number | Date | null): this {
62108
return this.addComparison(selector, 'like', value);
63109
}
64110

65111
/** Add a not like comparison to the query.
66-
*
112+
*
67113
* @param selector - The field name
68114
* @param value - The value to compare
69-
*
115+
*
70116
* @returns The builder instance
71117
*/
72118
notLike(selector: TSelector, value: string | number | Date | null): this {
@@ -89,4 +135,4 @@ export default RSQLBuilderSample;
89135
[npm-url]: https://npmjs.org/package/rsql-query-builder
90136
[npm-license-image]: https://img.shields.io/npm/l/rsql-query-builder
91137
[coveralls-image]: https://coveralls.io/repos/github/woigl/rsql-query-builder/badge.svg?branch=main
92-
[coveralls-url]: https://coveralls.io/github/woigl/rsql-query-builder?branch=main
138+
[coveralls-url]: https://coveralls.io/github/woigl/rsql-query-builder?branch=main

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rsql-query-builder",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Library for building RSQL query strings.",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",

0 commit comments

Comments
 (0)