# yajm

> 'Yet Another Javascript Model' library

Latest version **0.3.0** (published 2014-06-17) · MIT license · 0 weekly downloads

## Install

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

## 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.3.0 |
| Published | 2014-06-17 |
| First published | 2014-06-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Aaron Qian |
| Maintainers | aq1018 |

## Links

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

## Recent versions

- 0.3.0 (latest) — 2014-06-17
- 0.2.4 — 2014-06-14
- 0.2.3 — 2014-06-14
- 0.2.2 — 2014-06-14
- 0.2.1 — 2014-06-14
- 0.2.0 — 2014-06-14
- 0.1.1 — 2014-06-13

## README

# Yet Another Javascript Model

Javascript Domain Model factory.

## Install

```
npm install yajm --save
```

## Usage

```js
var Model = require('yajm').Model;
var Types = require('yajm').Types;


// define a model class
var User = Model.define({
  id: Types.Integer,

  username: String,

  isAdmin: {
    type: Boolean,
    default: false
  },

  // array of string
  tags: [String],

  // array of anonymous contact model
  contacts: [{
    firstName: String,
    lastName: String,
    email: String
  }]

});

// create a user
var user = new User({
  id: '123',
  tags: ['foo', 'bar'],
  contacts: [{
    firstName: 'aaron',
    lastName: 'qian',
    email: 'aq@gmail'
  }]
});

// get attribute
user.id; // 123, note this is already been coreced into integer
user.tags; // ['foo', 'bar']

// set attribute and coersion
user.id = "456";
user.id; // 456
user.isAdmin = 'yes';
user.isAdmin // true

// setting undefined property:
user.undefinedProp = "foo";
// In strict mode, causes TypeError to be thrown.
// In non-strict mode, silently ignored.

// Silently ignored in either modes.
user._set('undefinedProp', 'foo');

```

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