0.1.0 • Published 9 years ago

mongoid2hashdir v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

Mongoid2Hashdir

Generate Hashed Directory Structure with Mongoid.

Example: 55307ca19be8008e14d4a2c4 -> /ef/fe

Build Status

Installation

npm install mongoid2hashdir

Please make sure Node.js is installed.

Test

npm run test

Documentation

  • toArray - Generate hashed directory structure and return it as array
  • toFilePath - Generate hashed directory structure and return it as path string
  • mkdirs - Generate hashed directory structure and create them

Arguments

  • mongoid - [String, Object] - Mongoid

Examples

mongoid2hashdir.toArray('55307ca19be8008e14d4a2c4')  // ['ef', 'fe']

Arguments

  • mongoid - [String, Object] - Mongoid

Examples

mongoid2hashdir.toFilePath('55307ca19be8008e14d4a2c4')  // '/ef/fe'

Arguments

  • mongoid - [String, Object] - Mongoid
  • basePath - [String] - Base Path
  • callback(err, fullPath) - [Function] - A callback which is called when directories are created, or an error occurs.

Examples

mongoid2hashdir.mkdirs(
  '55307ca19be8008e14d4a2c4',
  '/any/directory',
  function (err, fullPath) {
    console.log('fullPath: ', fullPath)
    // '/any/directory/ef/fe/55307ca19be8008e14d4a2c4' should be created or existed
  }
)