# data-store-local

> data-store-assignment

Latest version **1.0.0** (published 2021-01-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install data-store-local
pnpm add data-store-local
yarn add data-store-local
bun add data-store-local
```

## 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.0 |
| Published | 2021-01-01 |
| First published | 2021-01-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 70.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | dinesh babu |
| Maintainers | dinesh_babu |
| Keywords | local storage, key value data store |

## Links

- npm: https://www.npmjs.com/package/data-store-local
- Repository: https://github.com/dineshbabu853/Data-Store
- Homepage: https://github.com/dineshbabu853/Data-Store#readme
- Issues: https://github.com/dineshbabu853/Data-Store/issues
- npm.io page: https://npm.io/package/data-store-local

## Dependencies (1)

- [mocha](https://npm.io/package/mocha.md) ^8.2.1

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2021-01-01

## README

# Key Value Data-Store   
This is a file based Key value data store built using **node js**

## *Core Functionalities*
1. Supports CREATE , READ , DELETE and UPDATE operation   
2. Restricts key size to 32 chars and value size to 16KB   
3. Allows client to instantiate the class and work on   
4. File can be created using optional file path , if it is not provided it will be created in current working directory   
5. Allows only one client to access file at a time   
6. Every key will have a optional timeToLive property   
7. Uses Singleton approach   
8. Thread safe   

## *Steps to run file locally:*
1. run ```npm i``` to install dependencies   
2. run ```npm start``` to run the application [ This will run the sample client file provided in the repo ]    
3. run ```npm test``` to run tests

## *Usage*
**Import the data store**    
```
let dataStore = require("./src/dataStore")    
```

**Creating an instance for the dataStore**    
This takes two arguments *clientId* and *file path(optional)*    
*note:* `clientId` is a four digit number provided by user, it restricts the file access to only one client process at any given time in a computer    
```
let clientId = 2343; //sample clientId
let myDataStore = new dataStore(clientId);
let instance = myDataStore.getInstance()   
```

**Create operation**    
```
let key = "person1";
let value = { age: 22, userId: 2345, city: "chennai" };
let timeToLive = 3;
instance.create(key, value, timeToLive);
```

**Read operation**
```
let myValue = instance.get("person1");    
```

**Delete operation**
```
instance.delete("person1");   
```

**Update operation**
```
let newValue = { age: 24, userId: 2345, city: "pune" };
instance.update("person1", newValue);
```

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