{"name":"hyperdb","version":"4.9.4","description":"P2P Indexable Database","scripts":{"test":"standard && brittle test/*.js","generate":"rm -rf test/fixtures/generated && node test/fixtures/generate.js"},"exports":{".":"./index.js","./package":"./package.json","./builder":{"import":"./builder/index.mjs","default":"./builder/index.js"},"./runtime":{"import":"./runtime.mjs","default":"./runtime.js"}},"imports":{"fs":{"bare":"bare-fs","default":"fs"},"path":{"bare":"bare-path","default":"path"}},"dependencies":{"b4a":"^1.6.6","compact-encoding":"^2.15.0","generate-object-property":"^2.0.0","generate-string":"^1.0.1","hyperbee":"^2.20.4","hyperschema":"^1.9.2","index-encoder":"^3.2.0","rocksdb-native":"^3.0.0","streamx":"^2.20.0"},"devDependencies":{"brittle":"^3.7.0","hypercore":"^10.37.22","standard":"^17.1.0","test-tmp":"^1.2.1"},"repository":{"type":"git","url":"git+https://github.com/holepunchto/hyperdb.git"},"author":{"name":"Holepunch Inc"},"license":"Apache-2.0","bugs":{"url":"https://github.com/holepunchto/hyperdb/issues"},"homepage":"https://github.com/holepunchto/hyperdb","_id":"hyperdb@4.9.4","gitHead":"d699d965964cb53f7102bca6c4ee0d3b59e2dbe0","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-T/gzCBDMHuifeAAdtzSkXEEsKicEFt4GrU9xvTO6evLvRrWVdh8pwBNcSo8E8iivia0Ow/4DP0ZeTplTVHx3zA==","shasum":"a03b0e07f8b951019a85816b2721cd89c86bc507","tarball":"http://registry-npm.ywwl.com/hyperdb/download/hyperdb-4.9.4.tgz","fileCount":12,"unpackedSize":70912,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGdw2T8VfP3qot+ha55EYwNJh+RdjAG0nT4WvHSd/hrUAiB7IdQ3WkNpdZvPHwAz2sTobym7FcMyfaqwfO1XHxvYGA=="}],"size":18863,"noattachment":false,"key":"/hyperdb/-/hyperdb-4.9.4.tgz"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/hyperdb_4.9.4_1739707297038_0.5709132160598354"},"_hasShrinkwrap":false,"readme":"# hyperdb\n\nDatabase built for P2P and local indexing\n\n```\nnpm install hyperdb\n```\n\n## Usage\n\nFirst generate your definition with the builder.\nThe definition defines the schemas and collections you wanna use.\n\n```js\n// TODO (see ./example here for now)\n```\n\nThen boot your db. You can use the same definition for a fully local db and a P2P one.\n\n``` js\nconst HyperDB = require('hyperdb')\n\n// first choose your engine\nconst db = HyperDB.rocks('./my-rocks.db', require('./my-definition'))\n```\n\nIt is that simple.\n\n## API\n\n#### `db = Hyperdb.bee(hypercore, definition, [options])`\n\nMake a db backed by Hyperbee. P2P!\n\n#### `db = Hyperdb.rocks(path, definition, [options])`\n\nMake a db backed by RocksDB. Local only!\n\n#### `queryStream = db.find(collectionOrIndex, query, [options])`\n\nQuery the database. `collectionOrIndex` is the identifier you defined in your builder.\n\nThe query looks like this\n\n``` js\n{\n  gt: { ... },\n  gte: { ... },\n  lt: { ...},\n  lte: { ...}\n}\n```\n\nAnd options include\n\n```js\n{\n  limit, // how many max?\n  reverse // reverse stream?\n}\n```\n\nSee the basic tests for an easy example on how queries look like.\n\nThe `queryStream` is a streamx readable stream that yields the documents you search for.\n\nA query is always running on a snapshot, meaning any inserts/deletes you do while this is running\nwill not impact the query stream itself.\n\n#### `all = await queryStream.toArray()`\n\nStream helper to simply get all the remaining entries in the stream.\n\n#### `one = await queryStream.one()`\n\nStream helper to simply get the last entry in the stream.\n\n#### `doc = await db.findOne(collectionOrIndex, query, [options])`\n\nAlias for `await find(...).one()`\n\n#### `doc = await db.get(collection, query)`\n\nGet a document from a collection\n\n#### `{ count } = await db.stats(collectionOrIndex)`\n\nGet stats, about a collection or index with stats enabled.\n\n#### `await db.insert(collection, doc)`\n\nInsert a document into a collection. NOTE: you have to flush the db later for this to be persisted.\n\n#### `await db.delete(collection, query)`\n\nDelete a document from a collection. NOTE: you have to flush the db later for this to be persisted.\n\n#### `bool = db.updated([collection], [query])`\n\nReturns a boolean indicating if this database was updated. Pass a collection and doc query to know if\na specific record was updated.\n\n#### `await db.flush()`\n\nFlush all changes to the db\n\n#### `db.reload()`\n\nReload the internal snapshot. Clears the memory state.\n\n#### `db = db.snapshot()`\n\nMake a readonly snapshot of the database. All reads/streams are locked in time on a snapshot from the time you call the snapshot method.\n\n#### `db = db.transaction()`\n\nMake a writable snapshot of the database. All reads/streams are locked in time on a snapshot from the time you call the snapshot method.\nWhen you flush this one, it updates the main instance also.\n\n#### `await db.close()`\n\nClose the database. You have to close any snapshots you use also.\n\n## Builder API\n\nSee [example](./builder/example.js).\n\nEach field in the builder file is an object:\n```\n{\n  name: 'field-name',\n  type: 'uint', // a compact-encoding type, or a reference to another encoding defined in the builder file\n  required: true, // false for optional\n  array: false // Store an array of 'type', instead of just one (default false)\n}\n```\n\n## License\n\nApache-2.0\n","publish_time":1739707297231,"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"andrewosh","email":"andrewosh@gmail.com"}],"_cnpm_publish_time":1739707297231,"dist-tags":{"latest":"6.11.1","tmp":"4.22.3"}}