# modelx

> Simple base class for model with manager

Latest version **0.0.3** (published 2014-09-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install modelx
pnpm add modelx
yarn add modelx
bun add modelx
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2014-09-04 |
| First published | 2014-08-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Pavel Silin |
| Maintainers | fi11 |
| Keywords | models, inheritance, obx |

## Links

- npm: https://www.npmjs.com/package/modelx
- Repository: https://github.com/fi11/modelx
- Issues: https://github.com/fi11/modelx/issues
- npm.io page: https://npm.io/package/modelx

## Dependencies (1)

- [obx](https://npm.io/package/obx.md) ~0.0.2

## Recent versions

- 0.0.3 (latest) — 2014-09-04
- 0.0.2 — 2014-09-04
- 0.0.1 — 2014-08-28

## README

Simple base class for model with manager.

## Installation

```
$ npm install modelx
```

## Example

```js
var Model = require('modelx').Model;
var Manager = require('modelx').Manager;

function SomeManagerConstructor(name, ctx) {
    this.conn = ctx.connection;
    this.tableName = name.toLowerCase();
}

var SomeManager = Manager.create(SomeManagerConstructor, {
    insert: function(data) {
        this.conn.insert(this.tableName, data);
    }
});

var MyModel = Model.create('MyModel', {
    __managers: { db: SomeManager },
    create: function(data) {
        this.query('db').insert(data);
    }
});

var model = new MyModel(app);

model.create(data);

var ChildModel = MyModel.create('ChildModel', {
    __managers: { es: SearchManager },  // maybe Array;
    create: function(data) {
        this.query('db').insert(data);
        this.query('es').index(data);
    }
});

```
## Inherits

For inheritance detail see [obx](https://www.npmjs.org/package/obx)

## Running tests

```
$ make test
```

## Authors

  - [Pavel Silin](https://github.com/fi11)

# License

  MIT

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