🚀 Launch Week Day 3:Introducing Supply Chain Attack Campaigns Tracking.Learn More →
Socket
Book a DemoInstallSign in
Socket

mirrordb

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mirrordb

DB for Hypercore mirror configs

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

mirrordb

P2P database for blind mirrors and relays, backed by RocksDB or an Hyperbee.

API

myDB = new MirrorDB(storage)

storage is an Hypercore or a string with the path to where you want a RocksDB file to be created.

await myDB.insert(...records)

Inserts the records inside the database. Records should have the following schema:

{
    key, // a fixed32 hypercore key
    type, // an unsigned integer indicating the type of the key
    description // optional, a string describing the mirror
}

keyStream = myDB.list()

The keyStream is a streamx readable stream that yields the records in the database, ordered by key.

A query is always running on a snapshot, meaning any inserts/deletes you do while this is running will not impact the query stream itself.

keyStream = myDB.listByType(type)

Same as myDB.list(), but yields only elements of the selected key type. Example:

const keyStream = myDB.listByType(1)

all = await keyStream.toArray()

Stream helper to simply get all the remaining entries in the stream.

record = await myDB.get(key)

Get a record from the database.

randomRecord = await myDB.random()

Get a random record from the database.

randomRecord = await myDB.randomByType(type)

Like myDB.random(), but returns a random record of the selected key type. Example:

const randomRecord = await myDB.randomByType(0)

await myDB.delete(...keys)

Delete the keys records from the database.

CLI

mirrors insert [flags] <key>

Insert a key into the database

Flags:

--description | -d <description>

Add a description to the key

--type | -t <type>

Specify a type for the key, default is 0

mirrors get <key>

Get info about a specific key from the database

mirrors random [flags]

Get a random key from the database

Flags:

--type | -t <type>

Specify the type of the key to be randomly extracted

mirrors delete <key>

Remove a key from the database

mirrors list [flags]

Get a list of keys in the database

Flags:

--type | -t <type>

Show only keys of a specific type

mirrors replicate [key]

Seeds the database and prints its public key to console. If a database key argument is provided, it will replicate that.

License

Apache-2.0

FAQs

Package last updated on 18 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts