document-dataply 0.0.9-alpha.9 → 0.0.10-alpha.0

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.
@@ -1,7 +1,17 @@
1
1
  import type { DataplyTreeValue, Primitive } from '../../types';
2
2
  import { ValueComparator } from 'dataply';
3
3
  export declare class DocumentValueComparator<T extends DataplyTreeValue<U>, U extends Primitive> extends ValueComparator<T> {
4
+ private readonly _intlComparator;
4
5
  primaryAsc(a: T, b: T): number;
5
6
  asc(a: T, b: T): number;
6
7
  match(value: T): string;
8
+ /**
9
+ * 두 Primitive 값을 비교합니다.
10
+ */
11
+ private _compareDiff;
12
+ /**
13
+ * 두 v 값을 비교합니다. v는 Primitive 또는 Primitive[] (복합 인덱스)일 수 있습니다.
14
+ * 배열인 경우 element-by-element로 비교합니다.
15
+ */
16
+ private _compareValue;
7
17
  }
@@ -122,7 +122,7 @@ export declare class DocumentDataply<T extends DocumentJSON> {
122
122
  * @throws Error if query or orderBy contains non-indexed fields
123
123
  */
124
124
  select(query: Partial<DocumentDataplyQuery<T>>, options?: DocumentDataplyQueryOptions, tx?: Transaction): {
125
- stream: AsyncIterableIterator<DataplyDocument<T>>;
125
+ stream: () => AsyncIterableIterator<DataplyDocument<T>>;
126
126
  drain: () => Promise<DataplyDocument<T>[]>;
127
127
  };
128
128
  /**
@@ -110,6 +110,31 @@ export declare class DocumentDataplyAPI<T extends DocumentJSON> extends DataplyA
110
110
  * @returns The verbose query object
111
111
  */
112
112
  verboseQuery<U extends Partial<DocumentDataplyQuery<T>>, V extends DataplyTreeValue<U>>(query: Partial<DocumentDataplyQuery<U>>): Partial<DocumentDataplyQuery<V>>;
113
+ /**
114
+ * B-Tree 타입 인덱스의 선택도를 평가하고 트리에 부여할 조건을 산출합니다.
115
+ * 필드 매칭 여부를 검사하고, 연속된(Prefix) 조건에 대해 점수를 부여하며 Start/End 바운드를 구성합니다.
116
+ *
117
+ * @param indexName 평가할 인덱스의 이름 (예: idx_nickname_createdat)
118
+ * @param config 등록된 인덱스의 설정 객체
119
+ * @param query 쿼리 객체
120
+ * @param queryFields 쿼리에 포함된 필드 목록 집합
121
+ * @param treeTx 조회를 수행할 B-Tree 트랜잭션 객체
122
+ * @param orderByField 정렬에 사용할 필드명 (옵션)
123
+ * @returns B-Tree 인덱스 후보 정보 (조건, 점수, 커버된 필드 등), 적합하지 않으면 null
124
+ */
125
+ private evaluateBTreeCandidate;
126
+ /**
127
+ * FTS (Full Text Search) 타입 인덱스의 선택도를 평가합니다.
128
+ * 'match' 연산자가 쿼리에 존재하는지 확인하고, 검색용 토큰으로 분해(tokenize)하여 점수를 매깁니다.
129
+ *
130
+ * @param indexName 평가할 인덱스의 이름
131
+ * @param config 등록된 인덱스의 설정 객체
132
+ * @param query 쿼리 객체
133
+ * @param queryFields 쿼리에 포함된 필드 목록 집합
134
+ * @param treeTx 조회를 수행할 B-Tree 트랜잭션 객체
135
+ * @returns FTS 인덱스 후보 정보 (조건, 점수, 분석된 토큰 등), 적합하지 않으면 null
136
+ */
137
+ private evaluateFTSCandidate;
113
138
  /**
114
139
  * Choose the best index (driver) for the given query.
115
140
  * Scores each index based on field coverage and condition type.
@@ -265,7 +290,7 @@ export declare class DocumentDataplyAPI<T extends DocumentJSON> extends DataplyA
265
290
  * @throws Error if query or orderBy contains non-indexed fields
266
291
  */
267
292
  selectDocuments(query: Partial<DocumentDataplyQuery<T>>, options?: DocumentDataplyQueryOptions, tx?: Transaction): {
268
- stream: AsyncIterableIterator<DataplyDocument<T>>;
293
+ stream: () => AsyncIterableIterator<DataplyDocument<T>>;
269
294
  drain: () => Promise<DataplyDocument<T>[]>;
270
295
  };
271
296
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-dataply",
3
- "version": "0.0.9-alpha.9",
3
+ "version": "0.0.10-alpha.0",
4
4
  "description": "Simple and powerful JSON document database supporting complex queries and flexible indexing policies.",
5
5
  "license": "MIT",
6
6
  "author": "izure <admin@izure.org>",
@@ -42,7 +42,7 @@
42
42
  "dataply"
43
43
  ],
44
44
  "dependencies": {
45
- "dataply": "^0.0.24-alpha.7"
45
+ "dataply": "^0.0.25-alpha.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/jest": "^30.0.0",
@@ -51,4 +51,4 @@
51
51
  "ts-jest": "^29.4.6",
52
52
  "typescript": "^5.9.3"
53
53
  }
54
- }
54
+ }
package/readme.md CHANGED
@@ -85,7 +85,7 @@ async function main() {
85
85
  // Get all results
86
86
  const allResults = await query.drain();
87
87
  // Or iterate through results
88
- for await (const doc of query.stream) {
88
+ for await (const doc of query.stream()) {
89
89
  console.log(doc);
90
90
  }
91
91
 
@@ -188,7 +188,7 @@ For more information on performance optimization and advanced features, see [TIP
188
188
 
189
189
  - **Query Optimization**: Automatic index selection for maximum performance.
190
190
  - **Sorting and Pagination**: Detailed usage of `limit`, `orderBy`, and `sortOrder`.
191
- - **Memory Management**: When to use `stream` vs `drain()`.
191
+ - **Memory Management**: When to use `stream()` vs `drain()`.
192
192
  - **Performance**: Optimizing bulk data insertion using `insertBatch`.
193
193
  - **Indexing Policies**: Dynamic index creation and automatic backfilling.
194
194
  - **Composite Indexes**: Indexing multiple fields for complex queries.
@@ -226,7 +226,7 @@ Inserts multiple documents efficiently. Returns an array of `_ids` (`number[]`).
226
226
  ### `db.select(query, options?, tx?)`
227
227
  Searches for documents matching the query. Passing an empty object (`{}`) as the `query` retrieves all documents.
228
228
  Returns an object `{ stream, drain }`.
229
- - `stream`: An async iterator to traverse results one by one.
229
+ - `stream()`: An async iterator to traverse results one by one.
230
230
  - `drain()`: A promise that resolves to an array of all matching documents.
231
231
 
232
232
  ### `db.partialUpdate(query, newFields, tx?)`