Socket
Socket
Sign inDemoInstall

accountdown-model

Package Overview
Dependencies
90
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    accountdown-model

a wrapper around accountdown that provides a few additional features


Version published
Weekly downloads
3
Maintainers
1
Install size
2.64 MB
Created
Weekly downloads
 

Readme

Source

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

Installation

npm install --save accountdown-model

Usage

Currently you must use 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, 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

FAQs

Last updated on 23 Jul 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc