# accountdown-model

> a wrapper around accountdown that provides a few additional features

Latest version **1.1.1** (published 2015-07-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install accountdown-model
pnpm add accountdown-model
yarn add accountdown-model
bun add accountdown-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.1.1 |
| Published | 2015-07-23 |
| First published | 2015-06-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 10 |
| Maintainers | sethvincent |

## Links

- npm: https://www.npmjs.com/package/accountdown-model
- Repository: https://github.com/sethvincent/accountdown-model
- Homepage: https://github.com/sethvincent/accountdown-model#readme
- Issues: https://github.com/sethvincent/accountdown-model/issues
- npm.io page: https://npm.io/package/accountdown-model

## Dependencies (9)

- [cuid](https://npm.io/package/cuid.md) ^1.2.5
- [clone](https://npm.io/package/clone.md) ^1.0.2
- [extend](https://npm.io/package/extend.md) ^2.0.1
- [is-email](https://npm.io/package/is-email.md) ^0.1.1
- [subleveldown](https://npm.io/package/subleveldown.md) ^2.0.0
- [filter-object](https://npm.io/package/filter-object.md) ^1.1.2
- [is-my-json-valid](https://npm.io/package/is-my-json-valid.md) ^2.12.0
- [json-schema-defaults](https://npm.io/package/json-schema-defaults.md) ^0.1.1
- [level-simple-indexes](https://npm.io/package/level-simple-indexes.md) 0.0.2

## Recent versions

- 1.1.1 (latest) — 2015-07-23
- 1.1.0 — 2015-07-23
- 1.0.0 — 2015-06-08

## README

# accountdown-model

This module is a wrapper around accountdown that provides a few extra features: changing username & password, validation using json-schema, and simple indexing of properties.

It's meant to have roughly the same api & features as [level-model](http://npmjs.org/level-model)

## Installation

```
npm install --save accountdown-model
```

## Usage

Currently you must use [accountdown-basic](http://npmjs.org/accountdown-basic) and you must use `key` as the name of the identifier for the account. You also must pass the level db as an option. Basically, you'll want to set up the modules exactly like this:

```
var db = level('example')

function accountdownBasic (db, prefix) {
  return require('accountdown-basic')(db, prefix, { key: 'key' })
}

var accountdown = accountdown(sublevel(db, 'accounts'), {
  login: { basic: accountdownBasic }
})

var accounts = require('accountdown-model')(accountdown, { 
  db: db
})
```

Additionally, you can specify properties that should be stored in the `value` object of the account, and control which of those properties should be required and indexed.

An example:

```
var accounts = require('accountdown-model')(accountdown, { 
  db: db,
  properties: {
    username: { type: 'string' },
    email: { type: 'string' }
  },
  required: ['username', 'email'],
  indexKeys: ['username', 'email']
})
```

## API

Exactly the same as [accountdown](http://npmjs.org/accountdown), with these additions:

```
var accounts = require('accountdown-model')(accountdown, { 
  db: db
})
```

### `accounts.update(key, data, callback)`

Updates the indexes of the properties and saves the values.

### `accounts.changePassword(key, password, callback)`

### `accounts.changeUsername(key, username, callback)`

## License

MIT

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