<commit_before># eventastic [![Build Status](https://travis-ci.org/akoenig/eventastic.svg?branch=master)](https://travis-ci.org/akoenig/eventastic)

[WIP] An event store on top of RethinkDB.

## Usage

```typescript
import createEventStore, { createEvent } from "eventastic";

const app = async () => {
    const es = await createEventStore({
        host: 'localhost',
        port: 32793
    });

    const user: IUser = {
        username: "akoenig",
        firstname: "André",
        lastname: "König",
        email: "<EMAIL>",
        password: "<PASSWORD>....",
        salt: "852b85...."
    };

    const UserRegisteredEvent = createEvent<IUser>('UserRegisteredEvent');

    await es.commit(UserRegisteredEvent(user));
};
```

### Changefeed

`eventastic` comes with a changefeed implementation which allows for further processing the event after it has been persisted (e. g. publish to message broker, etc.).

```typescript
import createEventStore, { createEvent } from "eventastic";

const app = async() => {
    const es = await createEventStore({
        host: 'localhost',
        port: 32793
    });

    await es.changes((err: Error, event: IEvent<any>) => {
        if (err) {
            // Handle error ...
        }

        console.log(`A new event has been persisted: ${JSON.stringify(event)}.`);

        // Publish to message broker etc. ...
    });
};
```

### Projections

```typescript
<commit_msg>docs: fix typo<commit_after># eventastic [![Build Status](https://travis-ci.org/akoenig/eventastic.svg?branch=master)](https://travis-ci.org/akoenig/eventastic)

[WIP] An event store on top of RethinkDB.

## Usage

```typescript
import createEventStore, { createEvent } from "eventastic";

const app = async () => {
    const es = await createEventStore({
        host: 'localhost',
        port: 32793
    });

    const user: IUser = {
        username: "akoenig",
        firstname: "André",
        lastname: "König",
        email: "<EMAIL>",
        password: "<PASSWORD>....",
        salt: "<PASSWORD>...."
    };

    const UserRegisteredEvent = createEvent<IUser>('UserRegisteredEvent');

    await es.commit(UserRegisteredEvent(user));
};
```

### Changefeed

`eventastic` comes with a changefeed implementation which allows further processing of the event after it has been persisted (e. g. publish to message broker, etc.).

```typescript
import createEventStore, { createEvent } from "eventastic";

const app = async() => {
    const es = await createEventStore({
        host: 'localhost',
        port: 32793
    });

    await es.changes((err: Error, event: IEvent<any>) => {
        if (err) {
            // Handle error ...
        }

        console.log(`A new event has been persisted: ${JSON.stringify(event)}.`);

        // Publish to message broker etc. ...
    });
};
```

### Projections

```typescript

{'fraction_non_alphanumeric': 0.15010496850944716, 'fraction_numerical': 0.00874737578726382, 'mean_word_length': 2.8170894526034713, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 18, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3450984', 'n_tokens_mistral': 890, 'n_tokens_neox': 844, 'n_words': 234}