Skip to content

Commit f61c125

Browse files
committed
chore: bump version to 1.0.16 and enhance repository logging
- Add operationName parameter to repository methods for better log identification - Update logging output to include operationName in all repository operations - Improve code formatting in ManyToManyJoin interface
1 parent 2f6690d commit f61c125

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sqlkit",
3-
"version": "1.0.15",
3+
"version": "1.0.16",
44
"description": "A lightweight SQL builder for TypeScript",
55
"license": "MIT",
66
"author": {

src/repository/repository.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export class Repository<T> {
3939

4040
if (this.options?.logging) {
4141
console.log({
42+
operationName: payload.operationName,
4243
sql: builder.build().sql,
4344
values: builder.build().values,
4445
result: {
@@ -105,6 +106,7 @@ export class Repository<T> {
105106
where: WhereCondition<T>;
106107
data: Partial<T>;
107108
returning?: Array<keyof T>;
109+
operationName?: string;
108110
}): Promise<QueryResult<T>> {
109111
const { where, data, returning = ["*"] as any } = args;
110112

@@ -117,6 +119,7 @@ export class Repository<T> {
117119

118120
if (this.options?.logging) {
119121
console.log({
122+
operationName: args.operationName,
120123
sql: builder.build().sql,
121124
values: builder.build().values,
122125
result: {
@@ -129,17 +132,19 @@ export class Repository<T> {
129132
return result;
130133
}
131134

132-
async delete(arg: {
135+
async delete(args: {
133136
where: WhereCondition<T>;
134137
returning?: Array<keyof T>;
138+
operationName?: string;
135139
}): Promise<QueryResult<T> | null> {
136140
const builder = new DeleteQueryBuilder<T>(this.tableName, this.executor);
137141
const result = await builder
138-
.where(arg.where)
139-
.returning(arg.returning)
142+
.where(args.where)
143+
.returning(args.returning)
140144
.commit();
141145
if (this.options?.logging) {
142146
console.log({
147+
operationName: args.operationName,
143148
sql: builder.build().sql,
144149
values: builder.build().values,
145150
result: {

src/types/query.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export interface Join<T, F> {
4545
columns?: Array<keyof F>;
4646
}
4747

48-
export interface ManyToManyJoin<Pivot,Foreign> {
48+
export interface ManyToManyJoin<Pivot, Foreign> {
4949
table: string;
5050
as?: string;
5151
on: {
@@ -56,6 +56,7 @@ export interface ManyToManyJoin<Pivot,Foreign> {
5656
}
5757

5858
export interface QueryRowsPayload<T> {
59+
operationName?: string;
5960
where?: WhereCondition<T>;
6061
joins?: Join<T, any>[];
6162
with?: ManyToManyJoin<any, any>[];

0 commit comments

Comments
 (0)