# @lyrasearch/plugin-disk-persistence

> Disk persistence plugin for Lyra

Latest version **0.0.1-alpha.1** (published 2022-08-17) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @lyrasearch/plugin-disk-persistence
pnpm add @lyrasearch/plugin-disk-persistence
yarn add @lyrasearch/plugin-disk-persistence
bun add @lyrasearch/plugin-disk-persistence
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.1-alpha.1 |
| Published | 2022-08-17 |
| First published | 2022-08-09 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 57.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Michele Riva |
| Maintainers | rafaelgss, shogun_panda, micheleriva |
| Keywords | lyra, disk persistence, full-text search |

## Links

- npm: https://www.npmjs.com/package/@lyrasearch/plugin-disk-persistence
- npm.io page: https://npm.io/package/@lyrasearch/plugin-disk-persistence

## Dependencies (3)

- [dpack](https://npm.io/package/dpack.md) ^0.6.22
- [@nearform/lyra](https://npm.io/package/@nearform/lyra.md) ^0.0.4
- [@msgpack/msgpack](https://npm.io/package/@msgpack/msgpack.md) ^2.7.2

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 0.0.1-alpha.1 (latest) — 2022-08-17
- 0.0.1-alpha.0 — 2022-08-09

## README

# Disk Persistence Plugin

[![Tests](https://github.com/LyraSearch/plugin-disk-persistence/actions/workflows/tests.yml/badge.svg)](https://github.com/LyraSearch/plugin-disk-persistence/actions/workflows/tests.yml)

Experimental stage, use at your own risk.

# Installation

You can install the disk persistence plugin using `npm`, `yarn`, `pnpm`:

```
npm i @lyrasearch/plugin-disk-persistence
```

```
yarn add @lyrasearch/plugin-disk-persistence
```

```
pnpm add @lyrasearch/plugin-disk-persistence
```

# Usage

You can save and restore a database by using the methods exposed by the `plugin-disk-persistence` package. <br />

Given the following database:

```js
import { create, insert } from '@nearform/lyra'

const myPrimaryDB = create({
  schema: {
    quote: 'string',
    author: 'string'
  }
})

insert(myPrimaryDB, {
  quote: 'Impossible is for the unwilling',
  author: 'John Keats'
})

insert(myPrimaryDB, {
  quote: 'I have not failed. I’ve just found 10,000 ways that won’t work.',
  author: 'Thomas A. Edison'
})
```

you can save the database to disk:

```js
import { persist } from '@lyrasearch/plugin-disk-persistence'

persist(myPrimaryDB, 'binary')
```

Available formats are:

- `binary`: saves the database to a compressed, binary file using `dpack` algorithm (**recommended**)
- `json`: saves the database to a JSON file

The `persist` function accepts as a third argument the file name.
When no argument, a default name will be used: `lyra_bump_623432432`.

Note: you can use the environment variable `LYRA_DB_NAME` to override the default name.

At this point, you can also restore the database from disk:

```js
import { search } from '@nearform/lyra'
import { restore } from '@lyrasearch/plugin-disk-persistence'

const mySecondaryDB = restore('binary')

search(mySecondaryDB, {
  term: 'work'
})
```

# License
[Apache-2.0](/LICENSE.md)

---
_Source: https://npm.io/package/@lyrasearch/plugin-disk-persistence · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
