2.0.2 • Published 3 years ago
@inrixia/db v2.0.2
@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
import db from "@inrixia/db";
type MyObjectType = {
name: string;
age: number;
hobbies: string[];
};
const myObject = db<MyObjectType>("./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:
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,
});
1.9.1
3 years ago
1.9.0
3 years ago
2.0.2
3 years ago
2.0.1
3 years ago
2.0.0
3 years ago
1.8.0
4 years ago
1.7.3
4 years ago
1.7.2
4 years ago
1.7.1
4 years ago
1.6.2
5 years ago
1.7.0
5 years ago
1.6.1
5 years ago
1.6.0
5 years ago
1.5.1
5 years ago
1.5.0
5 years ago
1.4.0
5 years ago
1.3.3
5 years ago
1.3.2
5 years ago
1.3.1
5 years ago
1.3.0
5 years ago
1.2.2
5 years ago
1.2.0
5 years ago
1.2.1
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.1.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago