1.5.0 • Published 4 years ago

@nnode/core-data v1.5.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

data

Library to work with document repositories.

Usage

npm install @nnode/core-data

Usage Details

You have to create derived types for DocumentContext and Documents<T>. A DocumentContext represents the document store, which uses the meta__doctype to represent the document type.

Example

// Create interface that represent models.
export interface EnvironmentVariable {
  name: string
  value: string
}

export interface User {
  home: string
  username: string
}

// Create model documents.
export interface EnvironmentVariableDocument extends Document, EnvironmentVariable {
  timestamp: number
}

export interface UserDocument extends Document, User {
  timestamp: number
}

// Create primary document context.
export class TestContext extends DocumentContext<CouchConfig> {
  users: Users = new Users('user', this.store)
  variables: EnvironmentVariables = new EnvironmentVariables('env', this.store)

  initialize() {
    return Promise.resolve()
  }
}

// Create specific document stores.
export class EnvironmentVariables extends Documents<EnvironmentVariableDocument> {
  readonly indexes: PouchDB.Find.CreateIndexOptions[] = []

  protected get keyProperties(): string[] {
    return ['name']
  }
}

export class Users extends Documents<UserDocument> {
  readonly indexes: PouchDB.Find.CreateIndexOptions[] = []

  protected get keyProperties(): string[] {
    return ['username']
  }
}
1.5.0

4 years ago

1.4.1-next.0

4 years ago

1.4.0

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.2-next.0

4 years ago

1.3.0

4 years ago

1.3.0-next.2

4 years ago

1.3.0-next.0

4 years ago

1.3.0-next.1

4 years ago

1.2.8

4 years ago

1.2.8-next.2

4 years ago

1.2.8-next.1

4 years ago

1.2.7-next.1

4 years ago

1.2.7

4 years ago

1.2.7-next.0

4 years ago

1.2.6

4 years ago

1.2.8-next.0

4 years ago

1.2.6-next.1

4 years ago

1.2.6-next.0

4 years ago

1.2.5

4 years ago

1.2.5-next.1

4 years ago

1.2.5-next.0

4 years ago

1.2.4

4 years ago

1.2.4-next.0

4 years ago

1.2.3

4 years ago

1.2.3-next.1

4 years ago

1.2.1

4 years ago

1.2.3-next.0

4 years ago

1.2.2-next.0

4 years ago

1.2.1-next.0

4 years ago

1.2.1-next.1

4 years ago

1.2.0

4 years ago

1.1.2

4 years ago

1.1.2-next.2

4 years ago

1.1.2-next.1

4 years ago

1.1.1

4 years ago

1.1.2-next.0

4 years ago

1.1.0

4 years ago

1.0.1-next.0

4 years ago

1.0.0

4 years ago

1.0.0-next.1

4 years ago

0.1.1-canary.5

4 years ago

1.0.0-next.0

4 years ago

0.1.1-canary.2

4 years ago

0.1.1-canary.0

4 years ago

0.1.0

4 years ago

0.1.0-next.0

4 years ago

0.0.1-canary.71

4 years ago