Skip to content

Commit

Permalink
fix typo, factor out admonition (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwhinnery committed Sep 20, 2023
1 parent 30719a4 commit 2e2508d
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 124 deletions.
14 changes: 14 additions & 0 deletions kv/manual/_admonition.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
:::caution Deno KV is currently in beta

Deno KV is currently **experimental** and **subject to change**. While we do our
best to ensure data durability, data loss is possible, especially around Deno
updates.

Executing Deno programs that use KV currently requires the `--unstable` flag, as
below:

```sh
deno run -A --unstable my_kv_code.ts
```

:::
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
# Data Modeling in TypeScript

:::caution Deno KV is currently in beta

Deno KV is currently **experimental** and **subject to change**. While we do our
best to ensure data durability, data loss is possible, especially around Deno
updates.
import Admonition from "./_admonition.mdx";

Excuting Deno programs that use KV currently requires the `--unstable` flag, as
below:

```sh
deno run -A --unstable my_kv_code.ts
```
# Data Modeling in TypeScript

:::
<Admonition />

In TypeScript applications, it is usually desirable to create strongly-typed,
well-documented objects to contain the data that your application operates on.
Expand Down Expand Up @@ -110,7 +99,7 @@ that can operate on your DTOs.
## Encapsulating business logic with a service layer

When your application's persistence needs become more complex - such as when you
need to create [secondary indexes](./secondary_indexes.md) to query your data by
need to create [secondary indexes](./secondary_indexes.mdx) to query your data by
different keys, or maintain relationships between objects - you will want to
create a set of functions to sit on top of your DTOs to ensure that the data
being passed around is valid (and not merely typed correctly).
Expand Down
39 changes: 14 additions & 25 deletions kv/manual/index.md → kv/manual/index.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Admonition from "./_admonition.mdx";

# Deno KV Quick Start

**Deno KV** is a
Expand All @@ -6,22 +8,9 @@ built directly into the Deno runtime, available in the
[`Deno.Kv` namespace](https://deno.land/api?unstable&s=Deno.Kv). It can be used
for many kinds of data storage use cases, but excels at storing simple data
structures that benefit from very fast reads and writes. Deno KV is available in
the Deno CLI and on [Deno Deploy](./on_deploy.md).

:::caution Deno KV is currently in beta

Deno KV is currently **experimental** and **subject to change**. While we do our
best to ensure data durability, data loss is possible, especially around Deno
updates.

Excuting Deno programs that use KV currently requires the `--unstable` flag, as
below:

```sh
deno run -A --unstable my_kv_code.ts
```
the Deno CLI and on [Deno Deploy](./on_deploy.mdx).

:::
<Admonition />

Let's walk through the key features of Deno KV.

Expand All @@ -42,7 +31,7 @@ const kv = await Deno.openKv();
Data in Deno KV is stored as key-value pairs, much like properties of a
JavaScript object literal or a
[Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map).
[Keys](./key_space.md) are represented as an array of JavaScript types, like
[Keys](./key_space.mdx) are represented as an array of JavaScript types, like
`string`, `number`, `bigint`, or `boolean`. Values can be arbitrary JavaScript
objects. In this example, we create a key-value pair representing a user's UI
preferences, and save it with
Expand Down Expand Up @@ -70,7 +59,7 @@ console.log(savedPrefs.value);
console.log(savedPrefs.versionstamp);
```

Both `get` and `list` [operations](./operations.md) return a
Both `get` and `list` [operations](./operations.mdx) return a
[KvEntry](https://deno.land/api?s=Deno.KvEntry&unstable=) object with the
following properties:

Expand Down Expand Up @@ -131,7 +120,7 @@ key after the prefix. So KV pairs with these keys:
Will be returned in that order by `kv.list()`.

Read operations can either be performed in
[**strong or eventual consistency mode**](./operations.md). Strong consistency
[**strong or eventual consistency mode**](./operations.mdx). Strong consistency
mode guarantees that the read operation will return the most recently written
value. Eventual consistency mode may return a stale value, but is faster. By
contrast, writes are always performed in strong consistency mode.
Expand All @@ -149,7 +138,7 @@ await db.delete(["preferences", "alan"]);

## Atomic transactions

Deno KV is capable of executing [atomic transactions](./transactions.md), which
Deno KV is capable of executing [atomic transactions](./transactions.mdx), which
enables you to conditionally execute one or many data manipulation operations at
once. In the following example, we create a new preferences object only if it
hasn't been created already.
Expand All @@ -175,11 +164,11 @@ if (res.ok) {
}
```

Learn more about transactions in Deno KV [here](./transactions.md).
Learn more about transactions in Deno KV [here](./transactions.mdx).

## Improve querying with secondary indexes

[Secondary indexes](./secondary_indexes.md) store the same data by multiple
[Secondary indexes](./secondary_indexes.mdx) store the same data by multiple
keys, allowing for simpler quries of the data you need. Let's say that we need
to be able to access user preferences by both username AND email. To enable
this, you could provide a function that wraps the logic to save the preferences
Expand Down Expand Up @@ -214,21 +203,21 @@ async function getByEmail(email) {
}
```

Learn more about [secondary indexes in the manual here](./secondary_indexes.md).
Learn more about [secondary indexes in the manual here](./secondary_indexes.mdx).

## Production usage

Deno KV is available for use in live applications on
[Deno Deploy](./on_deploy.md). In production, Deno KV is backed by
[Deno Deploy](./on_deploy.mdx). In production, Deno KV is backed by
[FoundationDB](https://www.foundationdb.org/), the open source key-value store
created by Apple.

**No additional configuration is necessary** to run your Deno programs that use
KV on Deploy - a new Deploy database will be provisioned for you when required
by your code. Learn more about Deno KV on Deno Deploy [here](./on_deploy.md).
by your code. Learn more about Deno KV on Deno Deploy [here](./on_deploy.mdx).

## Next steps

At this point, you're just beginning to scratch the surface with Deno KV. Be
sure to check out our guide on the [Deno KV key space](./key_space.md), and a
sure to check out our guide on the [Deno KV key space](./key_space.mdx), and a
collection of [tutorials and example applications](../tutorials/index.md) here.
17 changes: 3 additions & 14 deletions kv/manual/key_expiration.md → kv/manual/key_expiration.mdx
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
# Key Expiration

:::caution Deno KV is currently in beta

Deno KV is currently **experimental** and **subject to change**. While we do our
best to ensure data durability, data loss is possible, especially around Deno
updates.
import Admonition from "./_admonition.mdx";

Excuting Deno programs that use KV currently requires the `--unstable` flag, as
below:

```sh
deno run -A --unstable my_kv_code.ts
```
# Key Expiration

:::
<Admonition />

Since version 1.36.2, Deno KV supports key expiration. This allows an expiration
timestamp to be associated with a key, after which the key will be automatically
Expand Down
17 changes: 3 additions & 14 deletions kv/manual/key_space.md → kv/manual/key_space.mdx
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
# Key Space

:::caution Deno KV is currently in beta

Deno KV is currently **experimental** and **subject to change**. While we do our
best to ensure data durability, data loss is possible, especially around Deno
updates.
import Admonition from "./_admonition.mdx";

Excuting Deno programs that use KV currently requires the `--unstable` flag, as
below:

```sh
deno run -A --unstable my_kv_code.ts
```
# Key Space

:::
<Admonition />

Deno KV is a key value store. The key space is a flat namespace of
key+value+versionstamp pairs. Keys are sequences of key parts, which allow
Expand Down
17 changes: 3 additions & 14 deletions kv/manual/on_deploy.md → kv/manual/on_deploy.mdx
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
# KV on Deno Deploy

:::caution Deno KV is currently in beta

Deno KV is currently **experimental** and **subject to change**. While we do our
best to ensure data durability, data loss is possible, especially around Deno
updates.
import Admonition from "./_admonition.mdx";

Excuting Deno programs that use KV currently requires the `--unstable` flag, as
below:

```sh
deno run -A --unstable my_kv_code.ts
```
# KV on Deno Deploy

:::
<Admonition />

Deno Deploy now offers a built-in serverless key-value database called Deno KV.

Expand Down
17 changes: 3 additions & 14 deletions kv/manual/operations.md → kv/manual/operations.mdx
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
# Operations

:::caution Deno KV is currently in beta

Deno KV is currently **experimental** and **subject to change**. While we do our
best to ensure data durability, data loss is possible, especially around Deno
updates.
import Admonition from "./_admonition.mdx";

Excuting Deno programs that use KV currently requires the `--unstable` flag, as
below:

```sh
deno run -A --unstable my_kv_code.ts
```
# Operations

:::
<Admonition />

The Deno KV API provides a set of operations that can be performed on the key
space.
Expand Down
17 changes: 3 additions & 14 deletions kv/manual/secondary_indexes.md → kv/manual/secondary_indexes.mdx
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
# Secondary Indexes

:::caution Deno KV is currently in beta

Deno KV is currently **experimental** and **subject to change**. While we do our
best to ensure data durability, data loss is possible, especially around Deno
updates.
import Admonition from "./_admonition.mdx";

Excuting Deno programs that use KV currently requires the `--unstable` flag, as
below:

```sh
deno run -A --unstable my_kv_code.ts
```
# Secondary Indexes

:::
<Admonition />

Key-value stores like Deno KV organize data as collections of key-value pairs,
where each unique key is associated with a single value. This structure enables
Expand Down
17 changes: 3 additions & 14 deletions kv/manual/transactions.md → kv/manual/transactions.mdx
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
# Transactions

:::caution Deno KV is currently in beta

Deno KV is currently **experimental** and **subject to change**. While we do our
best to ensure data durability, data loss is possible, especially around Deno
updates.
import Admonition from "./_admonition.mdx";

Excuting Deno programs that use KV currently requires the `--unstable` flag, as
below:

```sh
deno run -A --unstable my_kv_code.ts
```
# Transactions

:::
<Admonition />

The Deno KV store utilizes _optimistic concurrency control transactions_ rather
than _interactive transactions_ like many SQL systems like PostgreSQL or MySQL.
Expand Down

0 comments on commit 2e2508d

Please sign in to comment.