serializable-bptree 5.0.5 → 5.1.1

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
@@ -63,6 +63,9 @@ tree.where({ equal: 1 }) // Map([{ key: 'a', value: 1 }])
63
63
  tree.where({ gt: 1 }) // Map([{ key: 'c', value: 3 }])
64
64
  tree.where({ lt: 2 }) // Map([{ key: 'a', value: 1 }])
65
65
  tree.where({ gt: 0, lt: 4 }) // Map([{ key: 'a', value: 1 }, { key: 'c', value: 3 }])
66
+ tree.where({ or: [3, 1] }) // Map([{ key: 'a', value: 1 }, { key: 'c', value: 3 }])
67
+
68
+ tree.clear()
66
69
  ```
67
70
 
68
71
  ## Why use a `serializable-bptree`?
@@ -320,32 +323,64 @@ import {
320
323
 
321
324
  ## Data Query Condition Clause
322
325
 
323
- This library supports various conditional clauses. Currently, it supports **gte**, **gt**, **lte**, **lt**, **equal**, **notEqual**, and **like** conditions. Each condition is as follows:
326
+ This library supports various conditional clauses. Currently, it supports **gte**, **gt**, **lte**, **lt**, **equal**, **notEqual**, **or**, and **like** conditions. Each condition is as follows:
324
327
 
325
328
  ### `gte`
326
329
 
327
330
  Queries values that are greater than or equal to the given value.
328
331
 
332
+ ```typescript
333
+ tree.where({ gte: 1 })
334
+ ```
335
+
329
336
  ### `gt`
330
337
 
331
338
  Queries values that are greater than the given value.
332
339
 
340
+ ```typescript
341
+ tree.where({ gt: 1 })
342
+ ```
343
+
333
344
  ### `lte`
334
345
 
335
346
  Queries values that are less than or equal to the given value.
336
347
 
348
+ ```typescript
349
+ tree.where({ lte: 5 })
350
+ ```
351
+
337
352
  ### `lt`
338
353
 
339
354
  Queries values that are less than the given value.
340
355
 
356
+ ```typescript
357
+ tree.where({ lt: 5 })
358
+ ```
359
+
341
360
  ### `equal`
342
361
 
343
362
  Queries values that match the given value.
344
363
 
364
+ ```typescript
365
+ tree.where({ equal: 3 })
366
+ ```
367
+
345
368
  ### `notEqual`
346
369
 
347
370
  Queries values that do not match the given value.
348
371
 
372
+ ```typescript
373
+ tree.where({ notEqual: 3 })
374
+ ```
375
+
376
+ ### `or`
377
+
378
+ Queries values that satisfy at least one of the given conditions. It accepts an array of conditions, and if any of these conditions are met, the data is included in the result.
379
+
380
+ ```typescript
381
+ tree.where({ or: [1, 2, 3] })
382
+ ```
383
+
349
384
  ### `like`
350
385
 
351
386
  Queries values that contain the given value in a manner similar to regular expressions. Special characters such as % and _ can be used.
@@ -357,6 +392,13 @@ Using **p_t**, it can match any string where the underscore is replaced by any c
357
392
 
358
393
  You can obtain matching data by combining these condition clauses. If there are multiple conditions, an **AND** operation is used to retrieve only the data that satisfies all conditions.
359
394
 
395
+ ```typescript
396
+ tree.where({ like: 'hello%' })
397
+ tree.where({ like: 'he__o%' })
398
+ tree.where({ like: '%world!' })
399
+ tree.where({ like: '%lo, wor%' })
400
+ ```
401
+
360
402
  ## Using Asynchronously
361
403
 
362
404
  Support for asynchronous trees has been available since version 3.0.0. Asynchronous is useful for operations with delays, such as file input/output and remote storage. Here is an example of how to use it:
@@ -421,6 +463,8 @@ await tree.where({ equal: 1 }) // Map([{ key: 'a', value: 1 }])
421
463
  await tree.where({ gt: 1 }) // Map([{ key: 'c', value: 3 }])
422
464
  await tree.where({ lt: 2 }) // Map([{ key: 'a', value: 1 }])
423
465
  await tree.where({ gt: 0, lt: 4 }) // Map([{ key: 'a', value: 1 }, { key: 'c', value: 3 }])
466
+
467
+ tree.clear()
424
468
  ```
425
469
 
426
470
  The implementation method for asynchronous operations is not significantly different. The **-Async** suffix is used instead of the **-Sync** suffix in the **BPTree** and **SerializeStrategy** classes. The only difference is that the methods become asynchronous. The **ValueComparator** class and similar value comparators do not use asynchronous operations.