Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inrixia/db.ts
Persistent object storage
https://github.com/inrixia/db.ts
databse json jsonstorage jsonstore persistent persistent-storage storage
Last synced: about 1 month ago
JSON representation
Persistent object storage
- Host: GitHub
- URL: https://github.com/inrixia/db.ts
- Owner: Inrixia
- Created: 2020-09-03T21:00:31.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-19T05:13:31.000Z (over 2 years ago)
- Last Synced: 2024-11-10T22:14:11.457Z (about 2 months ago)
- Topics: databse, json, jsonstorage, jsonstore, persistent, persistent-storage, storage
- Language: TypeScript
- Homepage:
- Size: 282 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## @inrixia/db
This project provides a function that returns a object, all changes to that object are synchronously persisted to disk as json.
Encryption and live updates are supported.
## Installation
```
npm install @inrixia/db
```## Usage
```ts
import db from "@inrixia/db";type MyObjectType = {
name: string;
age: number;
hobbies: string[];
};const myObject = db("./filename.json", {
template: {
name: "Bob",
age: 128,
hobbies: [],
},
forceCreate: true,
pretty: true,
});// use myObject as you wish, all changes will be persisted to disk
```## Options
The following options are supported:
```ts
db("./filename.json", {
// Template object to initialize with.
template: {},
// Key to use for encryption. (Enables encryption if specified)
cryptKey: "secret",
// Pretty print the JSON file. (Default: false)
pretty: true,
// Write out to file if it doesn't exist. (Default: false)
forceCreate: true,
// Asynchronously live update the object when the file is changed externally.
// Will enable forceCreate if true. (Default: false)
updateOnExternalChanges: true,
});
```