# fixer

> Setup your test database using fixtures in a breeze.

Latest version **0.0.2** (published 2013-06-06) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2013-06-06 |
| First published | 2013-05-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+5 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Olivier Lalonde |
| Maintainers | olalonde |
| Keywords | fixture, fixtures, mock, mocks, sequelize, orm, test, database |

## Links

- npm: https://www.npmjs.com/package/fixer
- Repository: git@github.com:olalonde/fixer
- Issues: https://github.com/olalonde/fixer/issues
- npm.io page: https://npm.io/package/fixer

## Dependencies (4)

- [async](https://npm.io/package/async.md) git://github.com/olalonde/async.git
- [debug](https://npm.io/package/debug.md) ~0.7.2
- [underscore](https://npm.io/package/underscore.md) ~1.4.4
- [underscore.string](https://npm.io/package/underscore.string.md) ~2.3.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2013-06-06
- 0.0.1 — 2013-05-28

## README

# Fixer

Node.js module to setup your test database using fixtures in a breeze. 
Inspired by [Rails fixtures](http://guides.rubyonrails.org/testing.html#the-low-down-on-fixtures). 

## Limitations

- Only supports `sequelize` ORM at the moment.
- I haven't tested many-to-many relationships for now but I will as soon as possible.

## Install

    npm install fixer

## Usage 

See [example/load_fixtures.js](./example/load_fixtures.js).

```javascript

var fixer = require('fixer');
/**
 * @param {Object} fixtures associative object. keys represent model names and values contain an array of fixtures for that model. fixture are simple associative objects.
 * @param {Object} models associative object. key represents the model
 * name and value is the Sequelize model
 */
fixer(fixtures, models).load(function (err) {
  if (err) return console.error(err);
  console.log('Finished loading fixtures into database.');
});

```

Example fixtures (in coffeescript):

`students.coffee`

```coffeescript
module.exports =
  oli:
    first_name: 'Olivier'
    last_name: 'Lalonde'
    email: 'olalonde@gmail.com'
    school: 'NYU'
  mark:
    first_name: 'Mark'
    last_name: 'Zuckerberg'
    email: 'mark@facebook.com'
    school: 'Harvard'
```

`schools.coffee`

```coffeescript
module.exports =
  'NYU':
    name: 'New York University'
    email: 'info@nyu.com'
  'Harvard':
    name: 'University of Harvard'
    email: 'info@harvard.edu'
```

You can reference other fixtures by their key. For example, `students.oli.school`
reference fixture `schools.NYU`.

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