# sails-enum-util

> Utility to create Enums that behave like models living in memory

Latest version **1.0.6** (published 2017-09-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install sails-enum-util
pnpm add sails-enum-util
yarn add sails-enum-util
bun add sails-enum-util
```

## 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.6 |
| Published | 2017-09-20 |
| First published | 2017-09-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Martin Asquino |
| Maintainers | masquino |
| Keywords | sails, enum |

## Links

- npm: https://www.npmjs.com/package/sails-enum-util
- Repository: https://github.com/martskins/sails-enum-util
- Homepage: https://github.com/martskins/sails-enum-util#readme
- Issues: https://github.com/martskins/sails-enum-util/issues
- npm.io page: https://npm.io/package/sails-enum-util

## Dependencies (1)

- [sails-memory](https://npm.io/package/sails-memory.md) ^0.10.7

## Recent versions

- 1.0.6 (latest) — 2017-09-20
- 1.0.5-a — 2017-09-20
- 1.0.5 — 2017-09-20
- 1.0.4 — 2017-09-20
- 1.0.3 — 2017-09-20
- 1.0.2 — 2017-09-20
- 1.0.1 — 2017-09-20
- 1.0.0 — 2017-09-20

## README

# INSTALLATION
```
npm install --save sails-enum-util
```

# A WORD OF CAUTION

This util uses `sails-memory` db adapter, which is not suitable for production. Use at your own risk.

# USAGE

The SailsEnum constructor takes two parameters:

**attributes**: An object representing the attributes of the model, as defined by any sails model. An attribute with the `primaryKey` setting set to `true` is required.

**data**: Array of elements to be created on sails lift (OPTIONAL)

The model's update, create, destroy, alter and drop methods are not allowed for models created with this util. Since they should be treated as static. If you try to use any of those it will throw an error.

### EXAMPLE
```js
/* api/models/Gender.js */

const Enum = require('sails-enum-util');

module.exports = new Enum({
	attributes: {
		code: {
			type: 'string',
			primaryKey: true
		},
		description: 'string'
	},
	data: [{
	   code: 'MALE',
	   description: 'Some description about the male gender'
	}, {
		code: 'FEMALE',
		description: 'Some description about the female gender'
	}, {
		....
	}]
})
```

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