Skip to content

Commit ec1a7f4

Browse files
authored
Merge pull request #219 from AthennaIO/develop
feat(query): add support to filter json values
2 parents 848ed4b + 4696633 commit ec1a7f4

24 files changed

Lines changed: 3079 additions & 4185 deletions

.github/workflows/cd.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
jobs:
99
build:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
id-token: write
1114
steps:
1215
- name: Checkout
1316
uses: actions/checkout@v2
@@ -32,8 +35,7 @@ jobs:
3235
id: release
3336

3437
- name: Publish to NPM Registry
35-
run: cd build && npm publish --access public
38+
run: cd build && npm publish --provenance --access public
3639
if: steps.release.outputs.released == 'true'
3740
env:
38-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3941
name: Deploy

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@athenna/database",
3-
"version": "5.38.0",
3+
"version": "5.39.0",
44
"description": "The Athenna database handler for SQL/NoSQL.",
55
"license": "MIT",
66
"author": "João Lenon <lenon@athenna.io>",

src/database/builders/QueryBuilder.ts

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export class QueryBuilder<
150150
/**
151151
* Calculate the average of a given column using distinct.
152152
*/
153-
public async count(column: string | ModelColumns<T> = '*'): Promise<string> {
153+
public async count(column: string | ModelColumns<T> = '*'): Promise<number> {
154154
return this.driver.count(column as string)
155155
}
156156

@@ -159,7 +159,7 @@ export class QueryBuilder<
159159
*/
160160
public async countDistinct(
161161
column: string | ModelColumns<T>
162-
): Promise<string> {
162+
): Promise<number> {
163163
return this.driver.countDistinct(column as string)
164164
}
165165

@@ -583,24 +583,6 @@ export class QueryBuilder<
583583
return this
584584
}
585585

586-
/**
587-
* Set a having exists statement in your query.
588-
*/
589-
public havingExists(closure: (query: Driver) => void) {
590-
this.driver.havingExists(closure)
591-
592-
return this
593-
}
594-
595-
/**
596-
* Set a having not exists statement in your query.
597-
*/
598-
public havingNotExists(closure: (query: Driver) => void) {
599-
this.driver.havingNotExists(closure)
600-
601-
return this
602-
}
603-
604586
/**
605587
* Set a having in statement in your query.
606588
*/
@@ -680,33 +662,6 @@ export class QueryBuilder<
680662
return this
681663
}
682664

683-
/**
684-
* Set an or having exists statement in your query.
685-
*/
686-
public orHavingExists(closure: (query: Driver) => void) {
687-
this.driver.orHavingExists(closure)
688-
689-
return this
690-
}
691-
692-
/**
693-
* Set an or having not exists statement in your query.
694-
*/
695-
public orHavingNotExists(closure: (query: Driver) => void) {
696-
this.driver.orHavingNotExists(closure)
697-
698-
return this
699-
}
700-
701-
/**
702-
* Set an or having in statement in your query.
703-
*/
704-
public orHavingIn(column: string | ModelColumns<T>, values: any[]) {
705-
this.driver.orHavingIn(column as string, values)
706-
707-
return this
708-
}
709-
710665
/**
711666
* Set an or having not in statement in your query.
712667
*/
@@ -887,6 +842,27 @@ export class QueryBuilder<
887842
return this
888843
}
889844

845+
public whereJson(
846+
column: string | ModelColumns<T>,
847+
operation: any,
848+
value?: any
849+
): this
850+
851+
public whereJson(column: string | ModelColumns<T>, value: any): this
852+
853+
/**
854+
* Set a where json statement in your query.
855+
*/
856+
public whereJson(
857+
column: string | ModelColumns<T>,
858+
operation: any,
859+
value?: any
860+
) {
861+
this.driver.whereJson(column as string, operation, value)
862+
863+
return this
864+
}
865+
890866
public orWhere(statement: (query: this) => void): this
891867
public orWhere(statement: Partial<T>): this
892868
public orWhere(statement: Record<string, any>): this
@@ -1030,6 +1006,27 @@ export class QueryBuilder<
10301006
return this
10311007
}
10321008

1009+
public orWhereJson(
1010+
column: string | ModelColumns<T>,
1011+
operation: Operations,
1012+
value?: any
1013+
): this
1014+
1015+
public orWhereJson(column: string | ModelColumns<T>, value: any): this
1016+
1017+
/**
1018+
* Set an orWhereJson statement in your query.
1019+
*/
1020+
public orWhereJson(
1021+
column: string | ModelColumns<T>,
1022+
operation: Operations,
1023+
value?: any
1024+
) {
1025+
this.driver.orWhereJson(column as string, operation, value)
1026+
1027+
return this
1028+
}
1029+
10331030
/**
10341031
* Set an order by statement in your query.
10351032
*/

0 commit comments

Comments
 (0)