supalite 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -289,7 +289,7 @@ const { data, error } = await client
289
289
  - `is(column, value)`: IS 연산자
290
290
  - `not(column, operator, value)`: Negates an operator (e.g., `not('column', 'is', null)`).
291
291
  - `contains(column, value)`: 배열/JSON 포함 여부
292
- - `or(conditions)`: OR 조건 (예: 'status.eq.active,role.eq.admin')
292
+ - `or(conditions)`: OR 조건 (예: 'status.eq.active,role.eq.admin', 'valid_until.is.null')
293
293
 
294
294
  ### 기타 메소드
295
295
 
@@ -41,7 +41,9 @@ export declare class QueryBuilder<T extends DatabaseSchema, S extends SchemaName
41
41
  not(column: string, operator: string, value: any): this;
42
42
  contains(column: string, value: any): this;
43
43
  in(column: string, values: any[]): this;
44
+ gt(column: string, value: any): this;
44
45
  gte(column: string, value: any): this;
46
+ lt(column: string, value: any): this;
45
47
  lte(column: string, value: any): this;
46
48
  order(column: string, options?: {
47
49
  ascending?: boolean;
@@ -122,11 +122,21 @@ class QueryBuilder {
122
122
  this.whereValues.push(...values);
123
123
  return this;
124
124
  }
125
+ gt(column, value) {
126
+ this.whereConditions.push(`"${column}" > $${this.whereValues.length + 1}`);
127
+ this.whereValues.push(value);
128
+ return this;
129
+ }
125
130
  gte(column, value) {
126
131
  this.whereConditions.push(`"${column}" >= $${this.whereValues.length + 1}`);
127
132
  this.whereValues.push(value);
128
133
  return this;
129
134
  }
135
+ lt(column, value) {
136
+ this.whereConditions.push(`"${column}" < $${this.whereValues.length + 1}`);
137
+ this.whereValues.push(value);
138
+ return this;
139
+ }
130
140
  lte(column, value) {
131
141
  this.whereConditions.push(`"${column}" <= $${this.whereValues.length + 1}`);
132
142
  this.whereValues.push(value);
@@ -161,7 +171,7 @@ class QueryBuilder {
161
171
  or(conditions) {
162
172
  const orParts = conditions.split(',').map(condition => {
163
173
  const [field, op, value] = condition.split('.');
164
- const validOperators = ['eq', 'neq', 'ilike', 'like', 'gt', 'gte', 'lt', 'lte'];
174
+ const validOperators = ['eq', 'neq', 'ilike', 'like', 'gt', 'gte', 'lt', 'lte', 'is'];
165
175
  if (!validOperators.includes(op)) {
166
176
  throw new Error(`Invalid operator: ${op}`);
167
177
  }
@@ -194,6 +204,13 @@ class QueryBuilder {
194
204
  return `"${field}" < $${paramIndex}`;
195
205
  case 'lte':
196
206
  return `"${field}" <= $${paramIndex}`;
207
+ case 'is':
208
+ if (processedValue === null) {
209
+ // Remove the null value from whereValues since we don't need a parameter for IS NULL
210
+ this.whereValues.pop();
211
+ return `"${field}" IS NULL`;
212
+ }
213
+ return `"${field}" IS $${paramIndex}`;
197
214
  default:
198
215
  return '';
199
216
  }
@@ -0,0 +1,33 @@
1
+ # 변경 보고서: `or` 메소드 내 `is` 연산자 지원
2
+
3
+ **날짜:** 2025년 11월 21일
4
+
5
+ ## 변경 유형
6
+
7
+ - [x] 기능 추가
8
+ - [ ] 버그 수정
9
+ - [ ] 성능 개선
10
+ - [ ] 문서 업데이트
11
+ - [ ] 기타
12
+
13
+ ## 변경 내용
14
+
15
+ ### `QueryBuilder`
16
+
17
+ - **`or` 메소드 개선**: `or` 메소드 내부에서 `is` 연산자를 사용할 수 있도록 지원을 추가했습니다. 이제 `valid_until.is.null`과 같은 표현을 통해 `IS NULL` 조건을 `OR` 절 안에서 사용할 수 있습니다.
18
+
19
+ **사용 예시:**
20
+
21
+ ```typescript
22
+ const { data } = await client
23
+ .from('credits')
24
+ .select('*')
25
+ .or('valid_until.is.null,valid_until.gt.now()');
26
+ ```
27
+
28
+ 위 코드는 `SELECT * FROM "public"."credits" WHERE ("valid_until" IS NULL OR "valid_until" > 'now()')` SQL 쿼리를 생성합니다.
29
+
30
+ ## 관련 파일
31
+
32
+ - `src/query-builder.ts`
33
+ - `README.md`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supalite",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "A lightweight TypeScript PostgreSQL client with Supabase-style API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",