nedb-engine 0.1.3 → 1.0.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/LICENSE +65 -201
- package/README.md +104 -17
- package/index.d.ts +27 -6
- package/nedb.darwin-arm64.node +0 -0
- package/nedb.linux-x64-gnu.node +0 -0
- package/nedb.win32-x64-msvc.node +0 -0
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1,201 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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 Derivative
|
|
95
|
-
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 do
|
|
117
|
-
not modify the License. You may add Your own attribution notices
|
|
118
|
-
within Derivative Works that You distribute, alongside or as an
|
|
119
|
-
addendum to the NOTICE text from the Work, provided that such
|
|
120
|
-
additional attribution notices cannot be construed as modifying
|
|
121
|
-
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 2026 Interchained
|
|
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.
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
Licensor: Interchained LLC, VibeCode 101, and/or the applicable copyright holders of NEDB
|
|
4
|
+
|
|
5
|
+
Licensed Work: NEDB, including all source code, documentation, examples, tests, build scripts, specifications, APIs, SDKs, packages, binaries, and derivative works distributed from or based on the NEDB repository.
|
|
6
|
+
|
|
7
|
+
Copyright: Copyright (c) 2026 Interchained LLC, VibeCode 101, and contributors. All rights reserved.
|
|
8
|
+
|
|
9
|
+
Change Date: Four years after the first publicly available distribution of each specific version of the Licensed Work under this License.
|
|
10
|
+
|
|
11
|
+
Change License: GNU Affero General Public License v3.0 or later.
|
|
12
|
+
|
|
13
|
+
Additional Use Grant:
|
|
14
|
+
|
|
15
|
+
You may use the Licensed Work only for non-production purposes, including evaluation, development, testing, research, local experimentation, security review, benchmarking, and personal learning.
|
|
16
|
+
|
|
17
|
+
No production use is granted automatically.
|
|
18
|
+
|
|
19
|
+
For clarity, the following uses are not permitted unless you have prior written permission from the Licensor:
|
|
20
|
+
|
|
21
|
+
1. Using the Licensed Work in production.
|
|
22
|
+
2. Using the Licensed Work to store, process, serve, index, replicate, query, or manage production data.
|
|
23
|
+
3. Offering the Licensed Work, or any derivative work, as a hosted, managed, embedded, bundled, white-labeled, commercial, paid, revenue-generating, or customer-facing product or service.
|
|
24
|
+
4. Offering database-as-a-service, storage-as-a-service, cache-as-a-service, search-as-a-service, analytics-as-a-service, AI-memory-as-a-service, agent-memory-as-a-service, blockchain-indexing-as-a-service, or any substantially similar service using the Licensed Work.
|
|
25
|
+
5. Using the Licensed Work to compete with NEDB, Interchained LLC, VibeCode 101, AiAssist Secure, or any affiliated product, service, infrastructure platform, database engine, AI runtime, agent platform, or hosted developer infrastructure.
|
|
26
|
+
6. Embedding the Licensed Work into commercial software, SaaS products, internal business systems, enterprise systems, hosted infrastructure, blockchain infrastructure, AI-agent infrastructure, or customer deliverables.
|
|
27
|
+
7. Removing, hiding, modifying, or misrepresenting this License, copyright notices, attribution notices, authorship notices, repository references, or licensing notices.
|
|
28
|
+
8. Circumventing license checks, access controls, paid licensing requirements, commercial-use restrictions, attribution requirements, or technical protections included with the Licensed Work.
|
|
29
|
+
9. Using the Licensed Work in a way that implies endorsement, partnership, sponsorship, certification, or approval by the Licensor without written permission.
|
|
30
|
+
10. Reselling, relicensing, sublicensing, renting, leasing, or otherwise commercially exploiting the Licensed Work except as expressly authorized in writing.
|
|
31
|
+
|
|
32
|
+
Additional production, commercial, hosted, enterprise, embedded, OEM, resale, white-label, managed-service, competitive, or otherwise restricted use grants are available only by separate written permission from the Licensor.
|
|
33
|
+
|
|
34
|
+
Written permission must be obtained from at least one of the following authorized licensing contacts:
|
|
35
|
+
|
|
36
|
+
[founders@vibecode-101.com](mailto:founders@vibecode-101.com)
|
|
37
|
+
[dev@interchained.org](mailto:dev@interchained.org)
|
|
38
|
+
|
|
39
|
+
Permission is valid only if it is expressly granted in writing by an authorized representative of the Licensor and specifically identifies the permitted use, scope, duration, parties, and any applicable commercial terms.
|
|
40
|
+
|
|
41
|
+
A general email conversation, informal message, pull request, issue comment, social media message, verbal discussion, repository access, package download, or contribution acceptance does not create a production, commercial, hosted, enterprise, resale, or competitive use license.
|
|
42
|
+
|
|
43
|
+
Terms:
|
|
44
|
+
|
|
45
|
+
The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, above, permitting limited production use.
|
|
46
|
+
|
|
47
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
|
|
48
|
+
|
|
49
|
+
If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase or obtain a separate commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
|
|
50
|
+
|
|
51
|
+
All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work, and the Change Date may vary for each version of the Licensed Work released by Licensor.
|
|
52
|
+
|
|
53
|
+
You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
|
|
54
|
+
|
|
55
|
+
Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
|
|
56
|
+
|
|
57
|
+
This License does not grant you any right in any trademark, service mark, trade name, logo, domain name, brand identity, product name, project name, or other identifier of Licensor or its affiliates, except as expressly required to preserve legally required notices.
|
|
58
|
+
|
|
59
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, TITLE, SECURITY, ACCURACY, AVAILABILITY, DATA INTEGRITY, PERFORMANCE, AND FITNESS FOR PRODUCTION USE.
|
|
60
|
+
|
|
61
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, LICENSOR SHALL NOT BE LIABLE FOR ANY CLAIM, DAMAGES, LOSSES, COSTS, EXPENSES, BUSINESS INTERRUPTION, LOST PROFITS, LOST REVENUE, LOST DATA, SECURITY INCIDENTS, SERVICE OUTAGES, OR OTHER LIABILITY ARISING FROM OR RELATED TO THE LICENSED WORK OR YOUR USE OF THE LICENSED WORK.
|
|
62
|
+
|
|
63
|
+
Notice:
|
|
64
|
+
|
|
65
|
+
The Business Source License is not an Open Source license. However, each version of the Licensed Work will become available under the Change License on the applicable Change Date, or on the fourth anniversary of the first publicly available distribution of that version under this License, whichever comes first.
|
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
Replay-protected · idempotent · relational · filterable · sortable · searchable · provable.
|
|
8
8
|
One Rust core → ships to **PyPI** and **npm** from a single source.
|
|
9
9
|
|
|
10
|
+
**[Website & docs → eth-interchained.github.io/nedb](https://eth-interchained.github.io/nedb/)**
|
|
11
|
+
|
|
10
12
|
</div>
|
|
11
13
|
|
|
12
14
|
---
|
|
@@ -18,6 +20,7 @@ Redis is fast because it's in-memory and simple — but relations are hand-rolle
|
|
|
18
20
|
- **Faster-than-Redis latency where it's honest to claim it** — NEDB runs **embedded, in-process**, so point reads pay *no socket hop*. The networked server (`nedbd`, RESP-compatible) competes on the Rust core's merits.
|
|
19
21
|
- **Replay protection + idempotency in the core, not the app.** Every write carries a strictly-monotonic per-client nonce and an optional idempotency key. Retries are no-ops; stale/out-of-order ops are rejected. This is built into one **hash-chained, append-only log**.
|
|
20
22
|
- **Time-travel.** Read the database *exactly as it existed* at any past sequence — `AS OF seq`. Debugging, audit, MVCC snapshots, and deterministic replay all fall out of the same log.
|
|
23
|
+
- **Durable persistence, Redis-style.** Point a database at a path and every op is appended to the hash-chained log on disk (and `fsync`'d); it reloads by replaying that log on open. It's exactly Redis's AOF model — except the append-only log is the *same tamper-evident chain* the engine already trusts, so `verify()` and `AS OF` hold across restarts and the log is never rewritten.
|
|
21
24
|
- **First-class relations.** Adjacency-list graph edges with O(1) traversal — *and the graph time-travels too*.
|
|
22
25
|
- **Filter / sort / search.** Equality, ordered, and full-text inverted indexes, maintained incrementally.
|
|
23
26
|
- **git-style files with maximum compression.** Content-defined chunking + content-addressed dedup + temperature tiers (fast warm codec, max-ratio cold archival). Every file version has a Merkle root you can **anchor on-chain**.
|
|
@@ -32,13 +35,14 @@ Redis is fast because it's in-memory and simple — but relations are hand-rolle
|
|
|
32
35
|
git clone https://github.com/Eth-Interchained/nedb && cd nedb
|
|
33
36
|
pip install -e . # pure-Python reference; no toolchain needed
|
|
34
37
|
python3 examples/demo.py # see every feature
|
|
35
|
-
python3 tests/test_nedb.py #
|
|
38
|
+
python3 tests/test_nedb.py # 11/11 invariants
|
|
36
39
|
```
|
|
37
40
|
|
|
38
41
|
```python
|
|
39
42
|
from nedb import NEDB
|
|
40
43
|
|
|
41
|
-
db = NEDB()
|
|
44
|
+
db = NEDB("./mydata") # durable: append-only log on disk, reloads on open
|
|
45
|
+
# db = NEDB() # (no path = purely in-memory)
|
|
42
46
|
db.create_index("users", "status", "eq")
|
|
43
47
|
db.create_index("users", "age", "ordered")
|
|
44
48
|
db.create_index("users", "bio", "search")
|
|
@@ -67,8 +71,63 @@ db.get("users", "alice", as_of=s)["city"] # -> "Austin"
|
|
|
67
71
|
# git-style files with Cascade compression + provable history
|
|
68
72
|
v1 = db.put_file("notes.txt", open("notes.txt","rb").read())
|
|
69
73
|
db.file_root("notes.txt", v1) # Merkle root — anchorable on ITC
|
|
74
|
+
|
|
75
|
+
# Durable + provable across restarts
|
|
76
|
+
db.close()
|
|
77
|
+
db = NEDB("./mydata") # replays the log on open
|
|
78
|
+
assert db.verify() # the hash chain is intact
|
|
79
|
+
db.get("users", "alice", as_of=s)["city"] # AS OF still works -> "Austin"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Persistence
|
|
85
|
+
|
|
86
|
+
NEDB persists the way Redis does — by writing the operations, not by dumping pages — because the engine's whole thesis is that **state is a pure function of the log**.
|
|
87
|
+
|
|
88
|
+
- `NEDB(path)` opens a **durable** database in a directory. Every op is appended to `log.aof` (one JSON line) and `fsync`'d; index configuration is snapshotted to `meta.json`. On open, NEDB replays the log to rebuild state.
|
|
89
|
+
- `NEDB()` with no path is **in-memory** (unchanged).
|
|
90
|
+
- The append-only log is the **same hash-chained, tamper-evident chain** that powers idempotency, replay protection, and time-travel — so `verify()`, `AS OF`, relations, and the anchorable head all survive a restart. The log is **never rewritten**, so the chain (and its commitment) stays provable.
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
db = NEDB("./mydata")
|
|
94
|
+
db.put("users", "alice", {"name": "Alice", "status": "active"})
|
|
95
|
+
db.close() # flush + fsync
|
|
96
|
+
|
|
97
|
+
again = NEDB("./mydata") # replays log.aof
|
|
98
|
+
assert again.verify() # chain intact across the restart
|
|
99
|
+
again.get("users", "alice") # -> {"name": "Alice", ...}
|
|
70
100
|
```
|
|
71
101
|
|
|
102
|
+
> Snapshotting (an RDB-style fast-load checkpoint that keeps the AOF intact) and Rust-core parity are tracked on the roadmap.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## nedbd — run NEDB as a server
|
|
107
|
+
|
|
108
|
+
For client/server setups (multiple apps, a remote admin UI like NEDB Studio, or just keeping the database in its own process), `pip install nedb-engine` ships a daemon. It runs the engine as a long-lived process and serves an HTTP/JSON API; each named database is a durable `NEDB(path)` held open in memory. Connect to it the way you'd connect to Redis or Postgres — over a URL.
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
nedbd # http://127.0.0.1:7070, data in ./nedb-data
|
|
112
|
+
# config via env: NEDBD_HOST, NEDBD_PORT, NEDBD_DATA, NEDBD_TOKEN (optional bearer auth)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# create a database (optionally seeded with indexes / rows / links)
|
|
117
|
+
curl -X POST localhost:7070/v1/databases -d '{"name":"shop","init":{
|
|
118
|
+
"indexes":[["users","status","eq"]],
|
|
119
|
+
"seed":{"users":[{"id":"u1","name":"Ada","status":"active"}]}}}'
|
|
120
|
+
|
|
121
|
+
# query it (real NQL, real engine)
|
|
122
|
+
curl -X POST localhost:7070/v1/databases/shop/query -d '{"nql":"FROM users WHERE status = \"active\""}'
|
|
123
|
+
|
|
124
|
+
# write, verify, time-travel — all server-side on the durable log
|
|
125
|
+
curl -X POST localhost:7070/v1/databases/shop/put -d '{"coll":"users","id":"u2","doc":{"name":"Bo"}}'
|
|
126
|
+
curl localhost:7070/v1/databases/shop/verify
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
API: `GET /health` · `GET|POST /v1/databases` · `GET|DELETE /v1/databases/<name>` · `POST …/query` · `POST …/put` · `POST …/index` · `POST …/link` · `DELETE …/rows/<coll>/<id>` · `GET …/verify` · `GET …/log`. Databases persist across daemon restarts (the engine replays its append-only log on open).
|
|
130
|
+
|
|
72
131
|
---
|
|
73
132
|
|
|
74
133
|
## NQL — the NEDB Query Language
|
|
@@ -87,18 +146,27 @@ FROM <collection>
|
|
|
87
146
|
|
|
88
147
|
---
|
|
89
148
|
|
|
90
|
-
## What's measured (
|
|
149
|
+
## What's measured (v0.4.1 · pure Python · Linux x86_64)
|
|
91
150
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
| GET (embedded, in-process) | **~1.2M ops/s** (~800 ns/op) |
|
|
95
|
-
| SET (logged + indexed) | ~77K ops/s |
|
|
96
|
-
| Indexed query latency | ~75 µs |
|
|
97
|
-
| File compression — warm (zlib stand-in) | **39.9×** |
|
|
98
|
-
| File compression — cold (LZMA archival) | **88.9×** |
|
|
99
|
-
| Cross-version dedup | 20 of 22 chunks reused on edit |
|
|
151
|
+
Numbers from `python3 bench/benchmarks.py` — reproducible, not cherry-picked.
|
|
152
|
+
Full results in [`bench/RESULTS.md`](bench/RESULTS.md).
|
|
100
153
|
|
|
101
|
-
|
|
154
|
+
| Operation | Throughput | Latency |
|
|
155
|
+
|---|---|---|
|
|
156
|
+
| GET (embedded, in-process) | **1.30M/s** | 0.77 µs |
|
|
157
|
+
| GET AS OF (time-travel) | 997K/s | 1.00 µs |
|
|
158
|
+
| PUT (logged, no index) | 63.7K/s | 15.7 µs |
|
|
159
|
+
| PUT durable (AOF + fsync) | 7.0K/s | 143 µs |
|
|
160
|
+
| QUERY: eq filter, eq index | **1.42M/s** | 0.71 µs |
|
|
161
|
+
| QUERY: eq filter, no index (scan) | 515K/s | 1.94 µs |
|
|
162
|
+
| QUERY: SEARCH (inverted index) | 467K/s | 2.14 µs |
|
|
163
|
+
| SQL SELECT → NQL (adapter) | 1.70M/s | 0.59 µs |
|
|
164
|
+
| AutoIndexDB wrapper overhead | ~0% | 0.54 µs |
|
|
165
|
+
| File compression — warm | **39.9×** | — |
|
|
166
|
+
| File compression — cold (LZMA) | **88.9×** | — |
|
|
167
|
+
| Cross-version dedup | 20 of 22 chunks | — |
|
|
168
|
+
|
|
169
|
+
The reference engine proves the **architecture**. Run `python3 bench/benchmarks.py --redis` to compare against Redis TCP on your own machine. The Rust core (`rust/`) is the future speed target.
|
|
102
170
|
|
|
103
171
|
---
|
|
104
172
|
|
|
@@ -116,7 +184,7 @@ The reference engine proves the **architecture**. The Rust core (`rust/`) is the
|
|
|
116
184
|
(time-travel) (graph, AS OF) eq/ordered/search CDC+dedup+tiers, Merkle roots
|
|
117
185
|
```
|
|
118
186
|
|
|
119
|
-
|
|
187
|
+
PyPI ships a **universal pure-Python wheel** (`pip install nedb-engine` works on every platform/Python, and includes the `nedbd` server) — the engine, persistence, and daemon are all pure Python. npm ships **napi-rs** native addons. Native PyO3 acceleration for PyPI is additive/roadmap (the public API is identical with or without it). A RESP-compatible `nedbd` wire protocol and a WASM build are also on the roadmap.
|
|
120
188
|
|
|
121
189
|
Full design: [`docs/SPEC.md`](docs/SPEC.md).
|
|
122
190
|
|
|
@@ -137,12 +205,31 @@ docs/SPEC.md architecture specification
|
|
|
137
205
|
## Roadmap
|
|
138
206
|
|
|
139
207
|
- [x] Reference engine: log, MVCC, relations, indexes, NQL, Cascade, Merkle
|
|
140
|
-
- [
|
|
141
|
-
- [ ]
|
|
142
|
-
- [ ] `
|
|
208
|
+
- [x] Durable persistence: append-only log (AOF) on disk + replay-on-open; `verify()` / `AS OF` survive restarts
|
|
209
|
+
- [ ] RDB-style snapshot checkpoint (fast load) that keeps the AOF chain intact
|
|
210
|
+
- [ ] Rust core parity (persistence in `nedb._native`) + criterion benches + `cargo test`
|
|
211
|
+
- [x] Universal pure-Python wheel + sdist on PyPI (installs everywhere; ships the `nedbd` command); napi-rs binaries on npm
|
|
212
|
+
- [ ] Additive native PyO3 acceleration wheels for PyPI (optional speed; same API)
|
|
213
|
+
- [x] `nedbd` server: HTTP/JSON daemon — durable, multi-database; `pip install` ships the `nedbd` command
|
|
214
|
+
- [ ] `nedbd`: RESP-compatible wire protocol + native protocol
|
|
143
215
|
- [ ] Similarity-picked deltas + schema-aware columnar transforms
|
|
144
216
|
- [ ] On-chain (ITC) root anchoring; WASM build
|
|
145
217
|
|
|
218
|
+
## NEDB Studio
|
|
219
|
+
|
|
220
|
+
The agentic, prompt-to-database GUI for NEDB — natural language → schema, NQL, seed data, and Python/Node snippets — lives in its own repo: **[Eth-Interchained/nedb-studio](https://github.com/Eth-Interchained/nedb-studio)** (Portal-powered, GPLv3).
|
|
221
|
+
|
|
146
222
|
## License
|
|
147
223
|
|
|
148
|
-
Apache-2.0
|
|
224
|
+
Apache-2.0 · © INTERCHAINED, LLC — [interchained.org](https://interchained.org). Built with [AiAssist](https://aiassist.net).
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Authors
|
|
229
|
+
|
|
230
|
+
Built by **[Mark Allen Evans Jr.](https://interchained.org)** (INTERCHAINED, LLC) with **Claude Sonnet 4.6** on [Hyperagent](https://hyperagent.com/refer/J2G6TCD7).
|
|
231
|
+
|
|
232
|
+
> *"Take one idea, turn it into an LP, then an app, then a system, then a platform, then infrastructure that is irreplaceable."*
|
|
233
|
+
|
|
234
|
+
[](https://hyperagent.com/refer/J2G6TCD7)
|
|
235
|
+
|
package/index.d.ts
CHANGED
|
@@ -4,13 +4,34 @@
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
6
|
export declare class NedbCore {
|
|
7
|
+
/** Create an in-memory database. */
|
|
7
8
|
constructor()
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
/** Open a durable database at `path` (AOF persistence). */
|
|
10
|
+
static open(path: string): NedbCore
|
|
11
|
+
createIndex(coll: string, field: string, kind: string): void
|
|
12
|
+
/** Auto-nonce put. `doc_json` is a JSON object string. Returns the stored doc. */
|
|
13
|
+
put(coll: string, id: string, docJson: string): string
|
|
14
|
+
/** Full put with optional client / nonce / idempotency key. */
|
|
15
|
+
putEx(coll: string, id: string, docJson: string, client?: string | undefined | null, nonce?: bigint | undefined | null, idem?: string | undefined | null): string
|
|
16
|
+
delete(coll: string, id: string): void
|
|
17
|
+
deleteEx(coll: string, id: string, client?: string | undefined | null, nonce?: bigint | undefined | null, idem?: string | undefined | null): void
|
|
18
|
+
link(frm: string, rel: string, to: string): void
|
|
19
|
+
unlink(frm: string, rel: string, to: string): void
|
|
12
20
|
get(coll: string, id: string): string | null
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
/** Time-travel: return the document as it was at sequence `as_of`. */
|
|
22
|
+
getAsOf(coll: string, id: string, asOf: bigint): string | null
|
|
23
|
+
/**
|
|
24
|
+
* Execute an NQL query string. Returns an array of JSON document strings.
|
|
25
|
+
* Full grammar supported: WHERE, ORDER BY, LIMIT, GROUP BY, TRAVERSE,
|
|
26
|
+
* SEARCH, AS OF, VALID AS OF, TRACE caused_by.
|
|
27
|
+
*/
|
|
28
|
+
query(nql: string): Array<string>
|
|
29
|
+
neighbors(frm: string, rel: string): Array<string>
|
|
30
|
+
neighborsAsOf(frm: string, rel: string, asOf: bigint): Array<string>
|
|
31
|
+
inbound(to: string, rel: string): Array<string>
|
|
32
|
+
inboundAsOf(to: string, rel: string, asOf: bigint): Array<string>
|
|
15
33
|
verify(): boolean
|
|
34
|
+
head(): string
|
|
35
|
+
seq(): bigint
|
|
36
|
+
flush(): void
|
|
16
37
|
}
|
package/nedb.darwin-arm64.node
CHANGED
|
Binary file
|
package/nedb.linux-x64-gnu.node
CHANGED
|
Binary file
|
package/nedb.win32-x64-msvc.node
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nedb-engine",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "NEDB —
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "NEDB — hash-chained, time-traveling, bi-temporal embedded database with Rust native core. SQL, Redis, MongoDB adapters. Causal Write Provenance. RESP2 wire protocol.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"files": ["index.js", "index.d.ts", "*.node", "README.md", "LICENSE"],
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"url": "git+https://github.com/Eth-Interchained/nedb.git"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
|
-
"database", "embedded", "mvcc", "time-travel", "
|
|
15
|
-
"
|
|
14
|
+
"database", "embedded", "mvcc", "time-travel", "bi-temporal", "causal-provenance",
|
|
15
|
+
"tamper-evident", "hash-chain", "versioning", "napi-rs", "rust", "nedb"
|
|
16
16
|
],
|
|
17
17
|
"engines": { "node": ">= 16" },
|
|
18
18
|
"napi": {
|