# that-simple-model

> A very simple set of Model decorators for for Typescript

Latest version **1.0.4** (published 2019-02-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install that-simple-model
pnpm add that-simple-model
yarn add that-simple-model
bun add that-simple-model
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2019-02-20 |
| First published | 2018-10-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | thatdevsteve |

## Links

- npm: https://www.npmjs.com/package/that-simple-model
- Repository: https://github.com/ThatDevCompany/that-simple-orm
- npm.io page: https://npm.io/package/that-simple-model

## Dependencies (1)

- [class-transformer](https://npm.io/package/class-transformer.md) 0.2.0

## Recent versions

- 1.0.4 (latest) — 2019-02-20
- 1.0.3 — 2019-02-19
- 1.0.2 — 2018-11-22
- 1.0.1 — 2018-11-21
- 0.0.18 — 2018-10-16
- 0.0.17 — 2018-10-12
- 0.0.16 — 2018-10-12
- 0.0.15 — 2018-10-12
- 0.0.14 — 2018-10-12
- 0.0.13 — 2018-10-03

## README

# That Simple Model
[![CircleCI](https://circleci.com/gh/ThatDevCompany/that-simple-model.svg?style=svg)](https://circleci.com/gh/ThatDevCompany/that-simple-model)

##  Overview
A simple set of Model definition Decorators

### Example Model
The following example describes a very simple Model with both a
Primary and a Secondary key

In this instance, the primary key (also known as the Partition key)
can be used for partitioning the database during persistence

```
@Model()
class Book {
    static meta: IMetaModel
    meta: IMetaModel

    @PrimaryKey
    clientId: string

    @SecondaryKey
    bookId: string

    title: string
}
```

The following shows a more traditional model with just a primary key
```
@Model()
class Book implements IModel {
    static meta: IMetaModel
    meta: IMetaModel

    @PrimaryKey
    bookId: string = uuid.v4()

    title: string
}
```

### Model decorator
The model decorator adds a IMetaModel object to the prototype of the class. This provides access to "introspect"
the meta data for the model.

The title, description and kind can all be set/overriden as part of the Model decorator

```
@Model({
    title: 'A Book',
    description: 'A collection of pages with words on',
    kind: 'tblBook'
})
class Book {
    static meta: IMetaModel
    meta: IMetaModel

    @PrimaryKey
    clientId: string

    @SecondaryKey
    bookId: string

    title: string
}
```

---
_Source: https://npm.io/package/that-simple-model · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
