0.3.109 • Published 2 years ago

tarant-db-persist v0.3.109

Weekly downloads
65
License
MIT
Repository
github
Last release
2 years 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

2 years ago

0.3.101

2 years ago

0.3.100

2 years ago

0.3.103

2 years ago

0.3.102

2 years ago

0.3.105

2 years ago

0.3.104

2 years ago

0.3.107

2 years ago

0.3.106

2 years ago

0.3.97

2 years ago

0.3.96

2 years ago

0.3.95

2 years ago

0.3.94

2 years ago

0.3.93

2 years ago

0.3.92

2 years ago

0.3.91

2 years ago

0.3.90

2 years ago

0.3.99

2 years ago

0.3.98

2 years ago

0.3.89

2 years ago

0.3.108

2 years ago

0.3.75

2 years ago

0.3.79

2 years ago

0.3.78

2 years ago

0.3.77

2 years ago

0.3.76

2 years ago

0.3.86

2 years ago

0.3.85

2 years ago

0.3.84

2 years ago

0.3.83

2 years ago

0.3.82

2 years ago

0.3.81

2 years ago

0.3.80

2 years ago

0.3.88

2 years ago

0.3.87

2 years 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

4 years ago

0.3.62

4 years ago

0.3.61

4 years ago

0.3.60

4 years ago

0.3.59

4 years ago

0.3.58

4 years ago

0.3.57

4 years ago

0.3.56

4 years ago

0.3.55

4 years ago

0.3.54

4 years ago

0.3.53

4 years ago

0.3.52

4 years ago

0.3.51

4 years ago

0.3.50

4 years ago

0.3.49

4 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

5 years ago

0.3.28

5 years ago

0.3.27

5 years ago

0.3.26

5 years ago

0.3.25

5 years ago

0.3.24

5 years ago

0.3.23

5 years ago

0.3.22

5 years ago

0.3.21

5 years ago

0.3.20

5 years ago

0.3.19

5 years ago

0.3.18

5 years ago

0.3.17

5 years ago

0.3.16

5 years ago

0.3.15

5 years ago

0.3.14

5 years ago

0.3.8

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.0

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.2.0

6 years ago

0.1.2

6 years ago

0.1.0

6 years ago

0.1.1

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago