README.md (1717B)
1 2 # nostrdb 3 4 ![ci](https://github.com/damus-io/nostrdb/actions/workflows/c-cpp.yml/badge.svg) 5 6 The unfairly fast nostr database backed by lmdb. 7 8 nostrdb stores nostr events as a custom in-memory representation that enables 9 zero-copy and O(1) access to all note fields. This is similar to flatbuffers 10 but it is custom built for nostr events. 11 12 These events are then memory-mapped inside lmdb, enabling insanely fast, 13 zero-copy access and querying. 14 15 This entire design of nostrdb is copied almost entirely from strfry[1], the 16 fastest nostr relay. The difference is that nostrdb is meant to be embeddable 17 as a C library into any application with full nostr query support. 18 19 [1]: https://github.com/hoytech/strfry 20 21 22 ## API 23 24 The API is *very* unstable. nostrdb is in heavy development mode so don't 25 expect any of the interfaces to be stable at this time. 26 27 ## CLI 28 29 nostrdb comes with a handy `ndb` command line tool for interacting with nostrdb 30 databases. The tool is relatively new, and only supports a few commands. 31 32 ### Usage 33 34 ``` 35 usage: ndb [--skip-verification] [-d db_dir] <command> 36 37 commands 38 39 stat 40 search [--oldest-first] [--limit 42] <fulltext query> 41 query [-k 42] [-k 1337] [-l 42] 42 import <line-delimited json file> 43 44 settings 45 46 --skip-verification skip signature validation 47 -d <db_dir> set database directory 48 ``` 49 50 ### Building 51 52 ```bash 53 $ make ndb 54 ``` 55 56 ### Fulltext Queries 57 58 nostrdb supports fulltext queries. You can import some test events like so: 59 60 ``` 61 $ make testdata/many-events.json 62 $ ndb --skip-verification import testdata/many-events.json 63 $ ndb search --limit 2 --oldest-first 'nosy ostrich' 64 65 [01] K<'ostrich' 7 1671217526 note_id:253309> 66 Q: What do you call a nosy ostrich? 67 A: A nosTrich! 68 ```