# corestore-metadata-db

> Simple Sqlite3 database to keep track of hypercores stored in a corestore

Latest version **0.1.0** (published 2022-08-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install corestore-metadata-db
pnpm add corestore-metadata-db
yarn add corestore-metadata-db
bun add corestore-metadata-db
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2022-08-22 |
| First published | 2022-08-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | H Degroote |
| Maintainers | hdegroote |

## Links

- npm: https://www.npmjs.com/package/corestore-metadata-db
- Repository: https://gitlab.com/HDegroote/corestore-metadata-db
- Homepage: https://gitlab.com/HDegroote/corestore-metadata-db#readme
- Issues: https://gitlab.com/HDegroote/corestore-metadata-db/issues
- npm.io page: https://npm.io/package/corestore-metadata-db

## Dependencies (2)

- [b4a](https://npm.io/package/b4a.md) ^1.6.0
- [better-sqlite3](https://npm.io/package/better-sqlite3.md) ^7.6.2

## Recent versions

- 0.1.0 (latest) — 2022-08-22

## README

# Corestore Metadata Db

Provides an interface to a simple Sqlite3 database which keeps track of hypercores stored in a corestore.
It can be used to persist information between corestore sessions,
since a corestore does not know which hypercores it contains on disk.

Note that this module is not concerned with whether the corestores and cores it
stores actually exist. This is the responsibility of the program which uses this module.

## Install
`npm add corestore-metadata-db`

## Usage
```
const DbInterface = require('corestore-metadata-db')

const dbInterface = DbInterface.initFromConnectionStr(':memory:')
const key = 'a'.repeat(64)
const key2 = 'b'.repeat(64)
const corestorePath = './my-corestore'

dbInterface.addCore({ name: 'myCore', key, corestorePath })
dbInterface.addCore({ name: 'myCore2', key: key2, corestorePath })

const coreInfo = dbInterface.getCoreByKey(key)
console.log(coreInfo)
/*
  DbCore {
    id: 1,
    name: 'myCore',
    key: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
    corestorePath: './my-corestore'
  }
*/

const coreInfos = dbInterface.getCoresOfCorestore(corestorePath)
console.log(coreInfos)

/*
[
  DbCore {
    id: 1,
    name: 'myCore',
    key: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
    corestorePath: './my-corestore'
  },
  DbCore {
    id: 2,
    name: 'myCore2',
    key: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
    corestorePath: './my-corestore'
  }
]
*/

---
_Source: https://npm.io/package/corestore-metadata-db · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
