Skip to content

Commit

Permalink
Merge pull request #139 from oliver-oloughlin/feature/version-history
Browse files Browse the repository at this point in the history
Feature/version history
  • Loading branch information
oliver-oloughlin authored Dec 2, 2023
2 parents 5dc00db + 08b5f7f commit 57022c0
Show file tree
Hide file tree
Showing 9 changed files with 972 additions and 111 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ _Supported Deno verisons:_ **^1.37.2**
- [findByPrimaryIndex()](#findbyprimaryindex)
- [findBySecondaryIndex()](#findbysecondaryindex)
- [findMany()](#findmany)
- [findHistory()](#findhistory)
- [findUndelivered()](#findundelivered)
- [add()](#add)
- [addMany()](#addmany)
Expand Down Expand Up @@ -157,6 +158,7 @@ const db = kvdex(kv, {
serialize: "auto"
}),
users: collection(UserSchema, {
history: true,
idGenerator: () => crypto.randomUUID(),
indices: {
username: "primary" // unique
Expand All @@ -173,8 +175,8 @@ const db = kvdex(kv, {
The schema definition contains collection builders, or nested schema
definitions. Collections can hold any type adhering to KvValue. Indexing can be
specified for collections of objects, while a custom id generator and
serialization can be set for all collections. The default id generator is
`ulid()` from Deno's standard library.
serialization can be set for all collections, in addition to enabling version
history. The default id generator is `ulid()` from Deno's standard library.

## Collection Methods

Expand Down Expand Up @@ -233,6 +235,16 @@ const userDocs2 = await db.users.findMany(["abc", 123, 123n], {
})
```

### findHistory()

Retrieve the version history of a document by id. A history entry contains a
timestamp, type of either "write" or "delete", and a copy of the document value
if the type is "write".

```ts
const history = await db.users.findHistory("user_id")
```

### findUndelivered()

Retrieve a document entry that was not delivered during an enqueue() operation
Expand Down
Loading

0 comments on commit 57022c0

Please sign in to comment.