Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MaximilianHeidenreich/DsDDB
A "Dead Simple Deno DataBase".
https://github.com/MaximilianHeidenreich/DsDDB
Last synced: 3 months ago
JSON representation
A "Dead Simple Deno DataBase".
- Host: GitHub
- URL: https://github.com/MaximilianHeidenreich/DsDDB
- Owner: MaximilianHeidenreich
- License: mit
- Created: 2020-12-19T20:58:29.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T12:19:09.000Z (almost 2 years ago)
- Last Synced: 2024-06-20T16:38:46.777Z (5 months ago)
- Language: TypeScript
- Homepage:
- Size: 39.1 KB
- Stars: 13
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-deno - dsddb - A dead simple persistant key-value database utilizing the JSON format. (Modules / Database)
README
DsDDB
A lightweight, developer friendly, key-value persistant storage solution for Deno projects.
Explore the docs »
Report Bug
·
Request Feature
## About The Project
I created this project because I needed a super simple key-value database which
could store data between script restarts. This is the result of that attempt.Obviously it can't hold up with "real" databases but if you are just starting
out developing a new project and you want a dead simple way to store data, this
probably is the solution for you.If you want to use it, please check out the docs for the project.
### Project Goals
- Store & Access key-value pairs (support for primitive & custom values)
- Write stored data to disk
- Load stored data from disk
- Expose a dead simple API to developers
- Don't include anything else other than Deno std
## Usage
This is the most basic example to get DsDDB up and running within your project.
For further information check out the
[API Documentation](https://doc.deno.land/https/deno.land/x/dsddb/mod.ts).> ! Note: If you are using the load() and write() methods, you need to run your
> Deno program with the "--allow-read --allow-write" flags.```TypeScript
// 1. Import DsDDB
import { DsDDB } from "https://deno.land/x/[email protected]/mod.ts";// 2. Create new DsDDB instance
const database = new DsDDB();// 3. Load from disk
await database.load();// 4. Use database
database.set("key1", "value 1"); // Always override value.
database.set("myKey", "Hello World", false); // Never override value.console.log(database.get("myKey"));
// 5. Write data to disk
await database.write();
```If you want to store custom data structures, there's a solution to that as well.
```TypeScript
// 1. Import DsDDB
import { DsDDB } from "https://deno.land/x/[email protected]/mod.ts";// 2. Define your data structure.
interface IDino {
name: string;
size: number;
birthday: Date;
}// 3. Define your data.
let data1: IDino = {
name: "Deno",
size: 69,
birthday: new Date(),
};// 4. Create new DsDDB instance
const database = new DsDDB();// 5. Load from disk
await database.load();// 6. Use database
database.set("deno", data1);console.log(database.get("deno"));
// 7. Write data to disk
await database.write();
```