@based/db 0.0.71 → 0.1.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.
Files changed (259) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +105 -77
  3. package/dist/lib/darwin_aarch64/include/libdeflate.h +23 -0
  4. package/dist/lib/darwin_aarch64/include/selva/db.h +0 -41
  5. package/dist/lib/darwin_aarch64/include/selva/fast_linear_search.h +6 -2
  6. package/dist/lib/darwin_aarch64/include/selva/fields.h +52 -37
  7. package/dist/lib/darwin_aarch64/include/selva/gmtime.h +137 -0
  8. package/dist/lib/darwin_aarch64/include/selva/mblen.h +40 -0
  9. package/dist/lib/darwin_aarch64/include/selva/selva_string.h +8 -5
  10. package/dist/lib/darwin_aarch64/include/selva/thread.h +37 -0
  11. package/dist/lib/darwin_aarch64/include/selva/types.h +18 -4
  12. package/dist/lib/darwin_aarch64/libdeflate.dylib +0 -0
  13. package/dist/lib/darwin_aarch64/libjemalloc_selva.2.dylib +0 -0
  14. package/dist/lib/darwin_aarch64/libnode-v22.node +0 -0
  15. package/dist/lib/darwin_aarch64/libnode-v23.node +0 -0
  16. package/dist/lib/darwin_aarch64/libnode-v24.node +0 -0
  17. package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
  18. package/dist/lib/darwin_aarch64/libxxhash.dylib +0 -0
  19. package/dist/lib/linux_aarch64/include/libdeflate.h +23 -0
  20. package/dist/lib/linux_aarch64/include/selva/db.h +0 -41
  21. package/dist/lib/linux_aarch64/include/selva/fast_linear_search.h +6 -2
  22. package/dist/lib/linux_aarch64/include/selva/fields.h +52 -37
  23. package/dist/lib/linux_aarch64/include/selva/gmtime.h +137 -0
  24. package/dist/lib/linux_aarch64/include/selva/mblen.h +40 -0
  25. package/dist/lib/linux_aarch64/include/selva/selva_string.h +8 -5
  26. package/dist/lib/linux_aarch64/include/selva/thread.h +37 -0
  27. package/dist/lib/linux_aarch64/include/selva/types.h +18 -4
  28. package/dist/lib/linux_aarch64/libdeflate.so +0 -0
  29. package/dist/lib/linux_aarch64/libnode-v22.node +0 -0
  30. package/dist/lib/linux_aarch64/libnode-v23.node +0 -0
  31. package/dist/lib/linux_aarch64/libnode-v24.node +0 -0
  32. package/dist/lib/linux_aarch64/libselva.so +0 -0
  33. package/dist/lib/linux_x86_64/include/libdeflate.h +23 -0
  34. package/dist/lib/linux_x86_64/include/selva/db.h +0 -41
  35. package/dist/lib/linux_x86_64/include/selva/fast_linear_search.h +6 -2
  36. package/dist/lib/linux_x86_64/include/selva/fields.h +52 -37
  37. package/dist/lib/linux_x86_64/include/selva/gmtime.h +137 -0
  38. package/dist/lib/linux_x86_64/include/selva/mblen.h +40 -0
  39. package/dist/lib/linux_x86_64/include/selva/selva_string.h +8 -5
  40. package/dist/lib/linux_x86_64/include/selva/thread.h +37 -0
  41. package/dist/lib/linux_x86_64/include/selva/types.h +18 -4
  42. package/dist/lib/linux_x86_64/libdeflate.so +0 -0
  43. package/dist/lib/linux_x86_64/libnode-v22.node +0 -0
  44. package/dist/lib/linux_x86_64/libnode-v23.node +0 -0
  45. package/dist/lib/linux_x86_64/libnode-v24.node +0 -0
  46. package/dist/lib/linux_x86_64/libselva.so +0 -0
  47. package/dist/src/client/index.d.ts +16 -21
  48. package/dist/src/client/index.js +48 -59
  49. package/dist/src/client/modify/Ctx.d.ts +38 -0
  50. package/dist/src/client/modify/Ctx.js +30 -0
  51. package/dist/src/client/modify/Tmp.d.ts +19 -0
  52. package/dist/src/client/modify/Tmp.js +67 -0
  53. package/dist/src/client/modify/create/index.d.ts +6 -0
  54. package/dist/src/client/modify/create/index.js +191 -0
  55. package/dist/src/client/modify/create/mark.d.ts +7 -0
  56. package/dist/src/client/modify/create/mark.js +42 -0
  57. package/dist/src/client/modify/cursor.d.ts +10 -0
  58. package/dist/src/client/modify/cursor.js +48 -0
  59. package/dist/src/client/modify/delete/index.d.ts +2 -0
  60. package/dist/src/client/modify/delete/index.js +39 -0
  61. package/dist/src/client/modify/drain.d.ts +7 -0
  62. package/dist/src/client/modify/drain.js +77 -0
  63. package/dist/src/client/modify/edges/binary.d.ts +3 -0
  64. package/dist/src/client/modify/edges/binary.js +28 -0
  65. package/dist/src/client/modify/edges/cardinality.d.ts +3 -0
  66. package/dist/src/client/modify/edges/cardinality.js +15 -0
  67. package/dist/src/client/modify/edges/header.d.ts +5 -0
  68. package/dist/src/client/modify/edges/header.js +21 -0
  69. package/dist/src/client/modify/edges/index.d.ts +3 -0
  70. package/dist/src/client/modify/edges/index.js +128 -0
  71. package/dist/src/client/modify/edges/reference.d.ts +3 -0
  72. package/dist/src/client/modify/edges/reference.js +31 -0
  73. package/dist/src/client/modify/edges/references.d.ts +3 -0
  74. package/dist/src/client/modify/edges/references.js +38 -0
  75. package/dist/src/client/modify/edges/separate.d.ts +3 -0
  76. package/dist/src/client/modify/edges/separate.js +24 -0
  77. package/dist/src/client/modify/edges/string.d.ts +3 -0
  78. package/dist/src/client/modify/edges/string.js +30 -0
  79. package/dist/src/client/modify/error.d.ts +7 -0
  80. package/dist/src/client/modify/error.js +68 -0
  81. package/dist/src/client/modify/expire/index.d.ts +2 -0
  82. package/dist/src/client/modify/expire/index.js +31 -0
  83. package/dist/src/client/modify/props/alias.d.ts +3 -0
  84. package/dist/src/client/modify/props/alias.js +26 -0
  85. package/dist/src/client/modify/props/binary.d.ts +5 -0
  86. package/dist/src/client/modify/props/binary.js +52 -0
  87. package/dist/src/client/modify/props/cardinality.d.ts +4 -0
  88. package/dist/src/client/modify/props/cardinality.js +46 -0
  89. package/dist/src/client/modify/props/delete.d.ts +3 -0
  90. package/dist/src/client/modify/props/delete.js +13 -0
  91. package/dist/src/client/modify/props/fixed.d.ts +4 -0
  92. package/dist/src/client/modify/props/fixed.js +105 -0
  93. package/dist/src/client/modify/props/increment.d.ts +3 -0
  94. package/dist/src/client/modify/props/increment.js +28 -0
  95. package/dist/src/client/modify/props/json.d.ts +3 -0
  96. package/dist/src/client/modify/props/json.js +5 -0
  97. package/dist/src/client/modify/props/main.d.ts +4 -0
  98. package/dist/src/client/modify/props/main.js +22 -0
  99. package/dist/src/client/modify/props/object.d.ts +3 -0
  100. package/dist/src/client/modify/props/object.js +37 -0
  101. package/dist/src/client/modify/props/reference.d.ts +6 -0
  102. package/dist/src/client/modify/props/reference.js +92 -0
  103. package/dist/src/client/modify/props/references.d.ts +3 -0
  104. package/dist/src/client/modify/props/references.js +231 -0
  105. package/dist/src/client/modify/props/separate.d.ts +3 -0
  106. package/dist/src/client/modify/props/separate.js +43 -0
  107. package/dist/src/client/modify/props/string.d.ts +5 -0
  108. package/dist/src/client/modify/props/string.js +51 -0
  109. package/dist/src/client/modify/props/text.d.ts +3 -0
  110. package/dist/src/client/modify/props/text.js +35 -0
  111. package/dist/src/client/modify/props/vector.d.ts +3 -0
  112. package/dist/src/client/modify/props/vector.js +30 -0
  113. package/dist/src/client/modify/resize.d.ts +3 -0
  114. package/dist/src/client/modify/resize.js +20 -0
  115. package/dist/src/client/modify/types.d.ts +3 -4
  116. package/dist/src/client/modify/types.js +2 -1
  117. package/dist/src/client/modify/uint.d.ts +7 -0
  118. package/dist/src/client/modify/uint.js +27 -0
  119. package/dist/src/client/modify/update/index.d.ts +3 -0
  120. package/dist/src/client/modify/update/index.js +75 -0
  121. package/dist/src/client/modify/upsert/index.d.ts +3 -0
  122. package/dist/src/client/modify/{upsert.js → upsert/index.js} +4 -4
  123. package/dist/src/client/modify/validate.d.ts +6 -0
  124. package/dist/src/client/modify/validate.js +24 -0
  125. package/dist/src/client/query/BasedDbQuery.d.ts +17 -14
  126. package/dist/src/client/query/BasedDbQuery.js +90 -93
  127. package/dist/src/client/query/{BasedIterable.d.ts → BasedQueryResponse.d.ts} +5 -4
  128. package/dist/src/client/query/{BasedIterable.js → BasedQueryResponse.js} +15 -10
  129. package/dist/src/client/query/aggregates/aggregation.d.ts +5 -3
  130. package/dist/src/client/query/aggregates/aggregation.js +105 -48
  131. package/dist/src/client/query/aggregates/types.d.ts +33 -11
  132. package/dist/src/client/query/aggregates/types.js +29 -11
  133. package/dist/src/client/query/debug.js +1 -1
  134. package/dist/src/client/query/display.d.ts +1 -1
  135. package/dist/src/client/query/display.js +21 -4
  136. package/dist/src/client/query/filter/FilterBranch.js +2 -2
  137. package/dist/src/client/query/filter/convertFilter.d.ts +3 -2
  138. package/dist/src/client/query/filter/convertFilter.js +13 -1
  139. package/dist/src/client/query/filter/createFixedFilterBuffer.js +16 -30
  140. package/dist/src/client/query/filter/createReferenceFilter.js +6 -20
  141. package/dist/src/client/query/filter/createVariableFilterBuffer.js +15 -32
  142. package/dist/src/client/query/filter/parseFilterValue.js +3 -11
  143. package/dist/src/client/query/filter/primitiveFilter.js +1 -1
  144. package/dist/src/client/query/filter/toBuffer.js +9 -15
  145. package/dist/src/client/query/filter/types.d.ts +6 -6
  146. package/dist/src/client/query/filter/types.js +8 -8
  147. package/dist/src/client/query/include/include.d.ts +3 -0
  148. package/dist/src/client/query/include/include.js +58 -0
  149. package/dist/src/client/query/include/props.d.ts +7 -7
  150. package/dist/src/client/query/include/props.js +26 -21
  151. package/dist/src/client/query/include/toByteCode.js +188 -0
  152. package/dist/src/client/query/include/utils.d.ts +3 -1
  153. package/dist/src/client/query/include/utils.js +13 -0
  154. package/dist/src/client/query/include/walk.d.ts +2 -2
  155. package/dist/src/client/query/include/walk.js +38 -23
  156. package/dist/src/client/query/query.d.ts +2 -3
  157. package/dist/src/client/query/query.js +2 -3
  158. package/dist/src/client/query/queryDef.d.ts +4 -2
  159. package/dist/src/client/query/queryDef.js +3 -5
  160. package/dist/src/client/query/queryDefToReadSchema.d.ts +3 -0
  161. package/dist/src/client/query/queryDefToReadSchema.js +126 -0
  162. package/dist/src/client/query/registerQuery.js +15 -4
  163. package/dist/src/client/query/search/index.d.ts +2 -1
  164. package/dist/src/client/query/search/index.js +9 -2
  165. package/dist/src/client/query/sort.js +3 -0
  166. package/dist/src/client/query/subscription/index.d.ts +1 -1
  167. package/dist/src/client/query/subscription/index.js +2 -2
  168. package/dist/src/client/query/subscription/types.d.ts +1 -1
  169. package/dist/src/client/query/thresholds.d.ts +1 -1
  170. package/dist/src/client/query/thresholds.js +1 -1
  171. package/dist/src/client/query/toByteCode/{toBuffer.js → toByteCode.js} +8 -8
  172. package/dist/src/client/query/types.d.ts +40 -25
  173. package/dist/src/client/query/types.js +2 -6
  174. package/dist/src/client/query/validation.d.ts +6 -0
  175. package/dist/src/client/query/validation.js +31 -7
  176. package/dist/src/client/setLocalClientSchema.js +6 -10
  177. package/dist/src/client/string.d.ts +3 -7
  178. package/dist/src/client/string.js +18 -47
  179. package/dist/src/hooks.d.ts +2 -3
  180. package/dist/src/hooks.js +14 -9
  181. package/dist/src/index.d.ts +3 -5
  182. package/dist/src/index.js +4 -6
  183. package/dist/src/native.d.ts +3 -2
  184. package/dist/src/native.js +9 -8
  185. package/dist/src/server/IoWorker.js +2 -3
  186. package/dist/src/server/QueryWorker.js +1 -1
  187. package/dist/src/server/blocks.js +5 -4
  188. package/dist/src/server/dbHash.js +1 -1
  189. package/dist/src/server/index.d.ts +4 -6
  190. package/dist/src/server/index.js +63 -96
  191. package/dist/src/server/migrate/index.d.ts +2 -4
  192. package/dist/src/server/migrate/index.js +31 -16
  193. package/dist/src/server/migrate/worker.js +2 -27
  194. package/dist/src/server/save.js +3 -2
  195. package/dist/src/server/schema.js +9 -19
  196. package/dist/src/server/start.d.ts +1 -0
  197. package/dist/src/server/start.js +18 -10
  198. package/dist/src/server/tree.d.ts +20 -0
  199. package/dist/src/server/tree.js +17 -2
  200. package/dist/src/server/workers/DbWorker.d.ts +1 -0
  201. package/dist/src/server/workers/DbWorker.js +8 -1
  202. package/dist/src/server/workers/io_worker.js +1 -1
  203. package/dist/src/server/workers/worker.js +9 -4
  204. package/dist/src/table.d.ts +4 -0
  205. package/dist/src/table.js +97 -0
  206. package/package.json +18 -17
  207. package/dist/lib/darwin_aarch64/include/selva/worker_ctx.h +0 -29
  208. package/dist/lib/linux_aarch64/include/selva/worker_ctx.h +0 -29
  209. package/dist/lib/linux_x86_64/include/selva/worker_ctx.h +0 -29
  210. package/dist/src/client/flushModify.d.ts +0 -36
  211. package/dist/src/client/flushModify.js +0 -197
  212. package/dist/src/client/modify/ModifyRes.d.ts +0 -23
  213. package/dist/src/client/modify/ModifyRes.js +0 -101
  214. package/dist/src/client/modify/alias.d.ts +0 -4
  215. package/dist/src/client/modify/alias.js +0 -57
  216. package/dist/src/client/modify/binary.d.ts +0 -6
  217. package/dist/src/client/modify/binary.js +0 -80
  218. package/dist/src/client/modify/cardinality.d.ts +0 -6
  219. package/dist/src/client/modify/cardinality.js +0 -63
  220. package/dist/src/client/modify/create.d.ts +0 -5
  221. package/dist/src/client/modify/create.js +0 -228
  222. package/dist/src/client/modify/delete.d.ts +0 -4
  223. package/dist/src/client/modify/delete.js +0 -47
  224. package/dist/src/client/modify/expire.d.ts +0 -3
  225. package/dist/src/client/modify/expire.js +0 -25
  226. package/dist/src/client/modify/fixed.d.ts +0 -5
  227. package/dist/src/client/modify/fixed.js +0 -235
  228. package/dist/src/client/modify/index.d.ts +0 -4
  229. package/dist/src/client/modify/index.js +0 -4
  230. package/dist/src/client/modify/json.d.ts +0 -4
  231. package/dist/src/client/modify/json.js +0 -26
  232. package/dist/src/client/modify/modify.d.ts +0 -5
  233. package/dist/src/client/modify/modify.js +0 -134
  234. package/dist/src/client/modify/references/appendEdgeRefs.d.ts +0 -4
  235. package/dist/src/client/modify/references/appendEdgeRefs.js +0 -33
  236. package/dist/src/client/modify/references/edge.d.ts +0 -5
  237. package/dist/src/client/modify/references/edge.js +0 -336
  238. package/dist/src/client/modify/references/getEdgeSize.d.ts +0 -3
  239. package/dist/src/client/modify/references/getEdgeSize.js +0 -27
  240. package/dist/src/client/modify/references/reference.d.ts +0 -11
  241. package/dist/src/client/modify/references/reference.js +0 -124
  242. package/dist/src/client/modify/references/references.d.ts +0 -16
  243. package/dist/src/client/modify/references/references.js +0 -316
  244. package/dist/src/client/modify/setCursor.d.ts +0 -5
  245. package/dist/src/client/modify/setCursor.js +0 -33
  246. package/dist/src/client/modify/string.d.ts +0 -5
  247. package/dist/src/client/modify/string.js +0 -71
  248. package/dist/src/client/modify/text.d.ts +0 -8
  249. package/dist/src/client/modify/text.js +0 -69
  250. package/dist/src/client/modify/update.d.ts +0 -6
  251. package/dist/src/client/modify/update.js +0 -90
  252. package/dist/src/client/modify/upsert.d.ts +0 -3
  253. package/dist/src/client/modify/vector.d.ts +0 -4
  254. package/dist/src/client/modify/vector.js +0 -53
  255. package/dist/src/client/query/include/toBuffer.js +0 -123
  256. package/dist/src/client/query/read/read.d.ts +0 -9
  257. package/dist/src/client/query/read/read.js +0 -483
  258. /package/dist/src/client/query/include/{toBuffer.d.ts → toByteCode.d.ts} +0 -0
  259. /package/dist/src/client/query/toByteCode/{toBuffer.d.ts → toByteCode.d.ts} +0 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Saulx B.V.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,16 +1,29 @@
1
1
  # BasedDb
2
2
 
3
- BasedDb is a powerful database solution that supports various data types, references, edges, and operations. It also offers concurrency handling, client-server architecture support, and more.
3
+ BasedDb is a powerful node graph based database solution that supports various
4
+ data types, references, edges, and operations. It also offers concurrency
5
+ handling, client-server architecture support, and more.
4
6
 
5
7
  ## Features
6
8
 
7
9
  - Schema definition and management
8
10
  - Data creation, querying, updating, and deletion
9
- - Support for strings, numbers, booleans, binaries, aliases, enums, and cardinality
10
- - Edges and references for advanced data modeling
11
+ - Supported field types
12
+ - `string`
13
+ - `text`, locale aware multi-language [text](./README_Text.md)
14
+ - `binary` strings
15
+ - `timestamp`
16
+ - numeric types: `number` (double-precision floating-point), `int8`, `uint8`, `int16`, `uint16`, `int32`, `uint64`
17
+ - `boolean`
18
+ - `alias`
19
+ - `enum`
20
+ - row and columnar vectors: `vector` and `colvec`
21
+ - `cardinality` set
22
+ - References and edge properties for advanced data modeling
11
23
  - Concurrency support for high-load scenarios
12
24
  - Client-server design for distributed systems
13
25
  - Checksum, analytics, and expiration features
26
+ - Async block based backups, i.e. only dirty blocks needs to be written on save
14
27
 
15
28
  ## Install
16
29
 
@@ -121,7 +134,7 @@ await db.setSchema({
121
134
  profilePicture: 'binary', // Raw binary data (Uint8Array)
122
135
  settings: 'json', // JSON object/array
123
136
  visits: 'cardinality', // HyperLogLog counter for unique values
124
- embedding: { type: 'vector', size: 5 }, // Fixed-size float vector (size from test)
137
+ embedding: { type: 'vector', size: 5, baseType: 'float32' }, // Fixed-size float vector (size from test)
125
138
  status: ['pending', 'active', 'inactive'], // Enum type
126
139
  countryCode: { type: 'string', maxBytes: 2 }, // String with max byte length
127
140
  nestedData: {
@@ -178,7 +191,77 @@ const userWithFriendId = await db.create('user', {
178
191
  const dialogFi = await db.create('dialog', { fun: 'hauskaa' }, { locale: 'fi' })
179
192
  ```
180
193
 
181
- ### Read (Query)
194
+ ### Update
195
+
196
+ ```typescript
197
+ // Update specific fields
198
+ await db.update('user', userId, { age: 31, isActive: false })
199
+
200
+ // Update using payload.id
201
+ await db.update('user', { id: userId, age: 32 })
202
+
203
+ // Atomic increment/decrement (number/timestamp)
204
+ await db.update('user', userId, {
205
+ age: { increment: 1 },
206
+ score: { decrement: 0.5 },
207
+ })
208
+
209
+ // Update references (single)
210
+ await db.update('user', userWithFriendId, { bestFriend: userId })
211
+
212
+ // Update references (list) - add, delete, update edge props
213
+ await db.update('user', userWithFriendId, {
214
+ friends: {
215
+ add: [userId],
216
+ delete: [friendId],
217
+ update: [{ id: userId, $friendshipLevel: 10 }],
218
+ },
219
+ })
220
+
221
+ // Replace references (list)
222
+ await db.update('user', userWithFriendId, { friends: [userId] }) // Replaces entire list
223
+
224
+ // Clear references
225
+ await db.update('user', userWithFriendId, { friends: null, bestFriend: null })
226
+
227
+ // Update cardinality field
228
+ await db.update('user', userId, { visits: 'newSession' }) // Adds 'newSession' if unique
229
+
230
+ // Update root properties
231
+ await db.update({ siteName: 'My Awesome Site V2' })
232
+
233
+ // Update text with specific locale
234
+ await db.update(
235
+ 'dialog',
236
+ dialogFi,
237
+ { fun: 'vielä hauskempaa' },
238
+ { locale: 'fi' },
239
+ )
240
+
241
+ // Update timestamp with string parsing
242
+ await db.update('user', userId, { updatedAt: 'now + 1h' }) // Relative time
243
+ ```
244
+
245
+ ### Upsert
246
+
247
+ Update if alias exists, otherwise create.
248
+
249
+ ```typescript
250
+ await db.upsert('user', {
251
+ alias: 'alice@example.com', // The alias to match
252
+ name: 'Alice Smith', // Field to update or set on create
253
+ age: 33, // Another field
254
+ })
255
+ ```
256
+
257
+ ### Delete
258
+
259
+ ```typescript
260
+ // Delete a node by ID
261
+ await db.delete('user', userId)
262
+ ```
263
+
264
+ ### Query
182
265
 
183
266
  The \`query\` method starts building a request to retrieve data.
184
267
 
@@ -235,7 +318,7 @@ Operators:
235
318
  - \`<\`: Less than (numbers, timestamps).
236
319
  - \`>=\`: Greater than or equal to.
237
320
  - \`<=\`: Less than or equal to.
238
- - \`has\`: Contains substring (case-insensitive by default for \`string\`, \`text\`).
321
+ - \`has\`: Contains substring (case sensitive by default for \`string\`, \`text\`, could be case insentive passing option argument).
239
322
  - \`like\`: Fuzzy search / similarity (for \`string\`, \`text\`, \`vector\`).
240
323
 
241
324
  **Filter Examples:**
@@ -405,6 +488,21 @@ await db.query('article').sort('email', 'desc').get()
405
488
  await db.query('event').sort('startTime').get()
406
489
  ```
407
490
 
491
+ The following data types doesnt support sort:
492
+
493
+ - Reference / References (you can if you use branched queries / nested include sintax) like
494
+
495
+ ```js await db
496
+ .query('actor')
497
+ .include('*')
498
+ .include((q) => q('movies').include('*').sort('name', 'desc'), '*')
499
+ .sort('name', 'asc')
500
+ .get()
501
+ ```
502
+
503
+ - Vector
504
+ - Binary
505
+
408
506
  #### \`.range(offset, limit)\`
409
507
 
410
508
  Paginates the results.
@@ -484,76 +582,6 @@ const specificUsers = await db
484
582
  .then((res) => res.toObject()) // Get plain objects
485
583
  ```
486
584
 
487
- ### Update
488
-
489
- ```typescript
490
- // Update specific fields
491
- await db.update('user', userId, { age: 31, isActive: false })
492
-
493
- // Update using payload.id
494
- await db.update('user', { id: userId, age: 32 })
495
-
496
- // Atomic increment/decrement (number/timestamp)
497
- await db.update('user', userId, {
498
- age: { increment: 1 },
499
- score: { decrement: 0.5 },
500
- })
501
-
502
- // Update references (single)
503
- await db.update('user', userWithFriendId, { bestFriend: userId })
504
-
505
- // Update references (list) - add, delete, update edge props
506
- await db.update('user', userWithFriendId, {
507
- friends: {
508
- add: [userId],
509
- delete: [friendId],
510
- update: [{ id: userId, $friendshipLevel: 10 }],
511
- },
512
- })
513
-
514
- // Replace references (list)
515
- await db.update('user', userWithFriendId, { friends: [userId] }) // Replaces entire list
516
-
517
- // Clear references
518
- await db.update('user', userWithFriendId, { friends: null, bestFriend: null })
519
-
520
- // Update cardinality field
521
- await db.update('user', userId, { visits: 'newSession' }) // Adds 'newSession' if unique
522
-
523
- // Update root properties
524
- await db.update({ siteName: 'My Awesome Site V2' })
525
-
526
- // Update text with specific locale
527
- await db.update(
528
- 'dialog',
529
- dialogFi,
530
- { fun: 'vielä hauskempaa' },
531
- { locale: 'fi' },
532
- )
533
-
534
- // Update timestamp with string parsing
535
- await db.update('user', userId, { updatedAt: 'now + 1h' }) // Relative time
536
- ```
537
-
538
- ### Upsert
539
-
540
- Update if alias exists, otherwise create.
541
-
542
- ```typescript
543
- await db.upsert('user', {
544
- alias: 'alice@example.com', // The alias to match
545
- name: 'Alice Smith', // Field to update or set on create
546
- age: 33, // Another field
547
- })
548
- ```
549
-
550
- ### Delete
551
-
552
- ```typescript
553
- // Delete a node by ID
554
- await db.delete('user', userId)
555
- ```
556
-
557
585
  ### Persistence & Control
558
586
 
559
587
  ```typescript
@@ -626,4 +654,4 @@ await clientDb.setSchema({
626
654
  ### Aggregations
627
655
 
628
656
  BasedDb support aggregate functions such as `sum('prop1','prop2')`, `count()`, etc and operations such as `groupBY('prop')`.
629
- See the specific doc [Aggregations](./README_Aggregate.md) for a detailed guide on its usage and features.
657
+ See the specific README [Aggregations](./README_Aggregate.md) for a detailed information on its usage and features.
@@ -212,6 +212,29 @@ libdeflate_decompress_ex(struct libdeflate_decompressor *decompressor,
212
212
  size_t *actual_in_nbytes_ret,
213
213
  size_t *actual_out_nbytes_ret);
214
214
 
215
+ /**
216
+ * Decompress a small number of bytes into out.
217
+ * The size of the output buffer doesn't need to align with the block size of
218
+ * the compressed input, unlike with the block decompression API. The downside
219
+ * of this decompression function is that it's much slower for longer output
220
+ * sizes. However, it can be much faster to use this function to extract a
221
+ * small number of bytes (e.g. 16 bytes) rather than decompressing a full block
222
+ * and then extracting a few bytes from it. This is interesting also because a
223
+ * deflate block can be at least theoretically be extremely long, and they
224
+ * are typically >= 1kB in size in the wild. Whereas, with this function the
225
+ * output buffer can be even fitted in the stack as it's small and it's size
226
+ * can be hard-coded.
227
+ * @param in is a pointer to the compressed data.
228
+ * @param in_nbytes is the size of in.
229
+ * @param out_nbytes_avail is the size of the out buffer.
230
+ * @param actual_out_nbytes_ret returns the actual number of bytes decompressed.
231
+ */
232
+ LIBDEFLATEEXPORT enum libdeflate_result
233
+ libdeflate_decompress_short(struct libdeflate_decompressor *decompressor,
234
+ const void *in, size_t in_nbytes,
235
+ void *out, size_t out_nbytes_avail,
236
+ size_t *actual_out_nbytes_ret);
237
+
215
238
  /**
216
239
  * ctrl libdeflate_decompress_block() stop condition
217
240
  */
@@ -292,47 +292,6 @@ struct SelvaNode *selva_prev_node(struct SelvaTypeEntry *type, struct SelvaNode
292
292
  SELVA_EXPORT
293
293
  struct SelvaNode *selva_next_node(struct SelvaTypeEntry *type, struct SelvaNode *node) __attribute__((nonnull));
294
294
 
295
- /**
296
- * \addtogroup db_cursor
297
- * @{
298
- */
299
-
300
- /**
301
- * Create a new cursor pointing to node.
302
- * If the node is deleted later then the cursor is updated to point to the next
303
- * node using selva_next_node().
304
- */
305
- SELVA_EXPORT
306
- cursor_id_t selva_cursor_new(struct SelvaTypeEntry *type, struct SelvaNode *node) __attribute__((nonnull));
307
-
308
- /**
309
- * Get a pointer to the node from a cursor.
310
- */
311
- SELVA_EXPORT
312
- struct SelvaNode *selva_cursor_get(struct SelvaTypeEntry *type, cursor_id_t id) __attribute__((nonnull));
313
-
314
- /**
315
- * Update a cursor to point to a new node.
316
- */
317
- SELVA_EXPORT
318
- int selva_cursor_update(struct SelvaTypeEntry *type, cursor_id_t id, struct SelvaNode *node) __attribute__((nonnull));
319
-
320
- /**
321
- * Delete a cursor.
322
- */
323
- SELVA_EXPORT
324
- void selva_cursor_del(struct SelvaTypeEntry *type, cursor_id_t id) __attribute__((nonnull));
325
-
326
- /**
327
- * Total count of cursors of type.
328
- */
329
- SELVA_EXPORT
330
- size_t selva_cursor_count(const struct SelvaTypeEntry *type) __attribute__((nonnull));
331
-
332
- /**
333
- * @}
334
- */
335
-
336
295
  /**
337
296
  * Total count of nodes of type.
338
297
  */
@@ -8,7 +8,8 @@
8
8
  #include "selva/types.h"
9
9
 
10
10
  struct SelvaNode;
11
- struct SelvaNodeReference;
11
+ struct SelvaNodeSmallReference;
12
+ struct SelvaNodeLargeReference;
12
13
 
13
14
  SELVA_EXPORT
14
15
  ssize_t fast_linear_search_uint32(const uint32_t arr[], size_t len, uint32_t x);
@@ -20,4 +21,7 @@ SELVA_EXPORT
20
21
  ssize_t fast_linear_search_node(const struct SelvaNode *arr[], size_t len, const struct SelvaNode *x);
21
22
 
22
23
  SELVA_EXPORT
23
- ssize_t fast_linear_search_references(const struct SelvaNodeReference *arr, size_t len, const struct SelvaNode *x);
24
+ ssize_t fast_linear_search_references_small(const struct SelvaNodeSmallReference *arr, size_t len, const struct SelvaNode *x);
25
+
26
+ SELVA_EXPORT
27
+ ssize_t fast_linear_search_references_large(const struct SelvaNodeLargeReference *arr, size_t len, const struct SelvaNode *x);