Skip to content

Commit

Permalink
📝 Updated docs for v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianHeidenreich committed Dec 19, 2020
1 parent c3c76b1 commit 4b1478c
Showing 1 changed file with 42 additions and 5 deletions.
47 changes: 42 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ If you want to use it, please check out the docs for the project.

### Project Goals

- Store & Access key-value pairs
- 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

<br></br>
<br>

<!-- USAGE -->
## Usage

This is the most basic example to get DsDDB up and running within your project. For further infroamtion check out the [API Documentation](https://doc.deno.land/https/deno.land/x/dsddb/mod.ts).

```TypeScript
// 1. Add import to your deps.ts
export { DsDDB } from "https://deno.land/x/dsddb@v1.0.1/mod.ts";
// 1. Import DsDDB
import { DsDDB } from "https://deno.land/x/dsddb@v1.1.0/mod.ts";

// 2. Create new DsDDB instance
const database = new DsDDB();
Expand All @@ -56,10 +56,47 @@ const database = new DsDDB();
await database.load();

// 4. Use database
if (!database.exists("myKey")) database.set("myKey", "Hello World");
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/dsddb@v1.1.0/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<IDino>();

// 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();
```

0 comments on commit 4b1478c

Please sign in to comment.