0.3.109 • Published 11 months ago

tarant-db-persist v0.3.109

Weekly downloads
65
License
MIT
Repository
github
Last release
11 months ago

tarant-db

Downloads npm npm GitHub Workflow Status All Contributors Maintainability Test Coverage PRs Welcome issues Welcome GitHub issues GitHub pull requests

Motivation

Provide the capabilities to actors on the backend to be persisted using waterline adapters.

Installation

add it to your project using npm install tarant-db-persist --save or yarn add tarant-db-persist

Usage

Initialize the sync client with the waterline adapter from the persist storage you will be interested on

import { ActorSystem, ActorSystemConfigurationBuilder } from 'tarant';
import * as diskAdapter from 'sails-disk';
import { PersistResolverMaterializer } from 'tarant-db-persist';
import AppActor from '../AppActor';

const config = {
    adapter: {
        type: diskAdapter,
        settings: {
          inMemoryOnly: true
        },
      },
      actorTypes: { AppActor }
  };

const persister = await PersistMaterializer.create(config)

const system : any = ActorSystem.for(ActorSystemConfigurationBuilder.define()
    .withMaterializers([persister])
    .withResolvers([persister])
    .done())  

your actors will require to implement IUpdatable (UpdateFrom) and IExportable (toJson)

import { Actor } from "tarant";
import { IUpdatable, IExportable } from "tarant-db-persist"

export default class AppActor extends Actor implements IUpdatable, IExportable {

  constructor(name: string) {
      super(name)
  }

  addOne() {
      this.counter++
  }

  toJson(){
        return {
            id: this.id,
            type:"AppActor",
            counter: this.counter
        }
    }

    updateFrom({ counter }: any): void {
        this.counter = counter
    }

    private counter = 1; 
}
Created my free logo at LogoMakr.com
0.3.109

11 months ago

0.3.101

1 year ago

0.3.100

1 year ago

0.3.103

1 year ago

0.3.102

1 year ago

0.3.105

1 year ago

0.3.104

1 year ago

0.3.107

1 year ago

0.3.106

1 year ago

0.3.97

1 year ago

0.3.96

1 year ago

0.3.95

1 year ago

0.3.94

1 year ago

0.3.93

1 year ago

0.3.92

1 year ago

0.3.91

1 year ago

0.3.90

1 year ago

0.3.99

1 year ago

0.3.98

1 year ago

0.3.89

1 year ago

0.3.108

1 year ago

0.3.75

2 years ago

0.3.79

1 year ago

0.3.78

2 years ago

0.3.77

2 years ago

0.3.76

2 years ago

0.3.86

1 year ago

0.3.85

1 year ago

0.3.84

1 year ago

0.3.83

1 year ago

0.3.82

1 year ago

0.3.81

1 year ago

0.3.80

1 year ago

0.3.88

1 year ago

0.3.87

1 year ago

0.3.74

2 years ago

0.3.73

2 years ago

0.3.72

2 years ago

0.3.71

2 years ago

0.3.70

2 years ago

0.3.69

2 years ago

0.3.64

2 years ago

0.3.68

2 years ago

0.3.67

2 years ago

0.3.66

2 years ago

0.3.65

2 years ago

0.3.63

3 years ago

0.3.62

3 years ago

0.3.61

3 years ago

0.3.60

3 years ago

0.3.59

3 years ago

0.3.58

3 years ago

0.3.57

3 years ago

0.3.56

3 years ago

0.3.55

3 years ago

0.3.54

3 years ago

0.3.53

3 years ago

0.3.52

3 years ago

0.3.51

3 years ago

0.3.50

3 years ago

0.3.49

3 years ago

0.3.48

4 years ago

0.3.47

4 years ago

0.3.46

4 years ago

0.3.45

4 years ago

0.3.44

4 years ago

0.3.43

4 years ago

0.3.42

4 years ago

0.3.41

4 years ago

0.3.40

4 years ago

0.3.39

4 years ago

0.3.38

4 years ago

0.3.37

4 years ago

0.3.36

4 years ago

0.3.35

4 years ago

0.3.34

4 years ago

0.3.33

4 years ago

0.3.32

4 years ago

0.3.31

4 years ago

0.3.30

4 years ago

0.3.29

4 years ago

0.3.28

4 years ago

0.3.27

4 years ago

0.3.26

4 years ago

0.3.25

4 years ago

0.3.24

4 years ago

0.3.23

4 years ago

0.3.22

4 years ago

0.3.21

4 years ago

0.3.20

4 years ago

0.3.19

4 years ago

0.3.18

4 years ago

0.3.17

4 years ago

0.3.16

4 years ago

0.3.15

4 years ago

0.3.14

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.0

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.2.0

5 years ago

0.1.2

5 years ago

0.1.0

5 years ago

0.1.1

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago