# sxli.db

> a database library

Latest version **1.0.4** (published 2022-09-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install sxli.db
pnpm add sxli.db
yarn add sxli.db
bun add sxli.db
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2022-09-17 |
| First published | 2022-09-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | sxlitudee |

## Links

- npm: https://www.npmjs.com/package/sxli.db
- Repository: https://github.com/Sxlitude/sxli.db
- Homepage: https://github.com/Sxlitude/sxli.db#readme
- Issues: https://github.com/Sxlitude/sxli.db/issues
- npm.io page: https://npm.io/package/sxli.db

## Dependencies (2)

- [phin](https://npm.io/package/phin.md) ^3.6.1
- [centra](https://npm.io/package/centra.md) ^2.5.0

## Recent versions

- 1.0.4 (latest) — 2022-09-17
- 1.0.3 — 2022-09-17
- 1.0.2 — 2022-09-17
- 1.0.0 — 2022-09-17

## README

### A Database Library
- Uses Caching for now; don't use on personal projects.
- My another github repo is the base of this lib
- Click here to see my own database repo.

#### Getting Started
- installing the database
```
npm install sxli.db
```
- initial code
```js
const Database = require('sxli.db');
const db = new Database();
```
Remember the library uses async/await so you need to either run the next code in async function or use `.then` method for response. I tried to make it similar to replitDB.

- setting a key
```js
/* Setting a String as value */
await db.set('foo', 'hello');

/* Setting a boolean as value */
await db.set('foo', true);

/* Setting an array as value */
const numbers = [ 1, 2, 3, 4, 5 ];
await db.set('foo', numbers);

/* Setting Object as value */
const data = {
  numbers: {
    odd: [1, 3, 5, 7, 9],
    even: [2, 4, 6, 8, 10],
    maxToTen: true
  },
  trigonometry: {
    terms: ['sin', 'cos', 'tan'],
    flipped: ['cosec', 'sec', 'cot']
  }
}

await db.set('foo', data)
```
- Getting a value
```js
/* By async keyword */
const value = await db.get('items');
console.log(value);

/* By then method */
db.get('items').then(value => {
  console.log(value);
});
```
- Deleting a value
```js
/* By async keyword */
await db.delete('xyz');

/* By then method */
db.get('xyz').then(() => {
  console.log('deleted!');
});
```
- listing values with prefix
```js
/* By async keyword */
const arrayOfKeys = await db.list('guild_');
console.log(arrayOfKeys);

/* By then method */
db.list('guild_').then(array => {
  console.log(array);
});
```

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