Module: database

  • Export constructor to create instance of Database
Author:
Source:
Example
const database = require('./lib/database')

var url = 'mongodb://localhost/gwisp'
var db = database(url)

Classes

Database

Members

(static, constant) DEFAULT_LOGGER :module:flatlog.FlatLog

  • Default logger use for database if logger parameter is not specify
Type:
Source:

Type Definitions

AssetDir

Path to directory contains an sample data of database. It must contains files below

  • region-iso-639.csv

This file contains region code follow iso 639. Database will use alpha-2 code. For quickly, simply is copy from source code file asset/sample-data/region-iso-639.csv

  • scheduler-001.json

This file contains an instance of scheduler. It must real scheduler. That mean people can use them. see document for module:collection.SCHEDULER_COL for detail of an scheduler object. If have not idea to change that, copy from source code in asset/sample-data/scheduler-001.json

  • scheduler-random.json

This file contains list of schedulers. It is generated by tools and have about more than 100 elements. That data use for test purpose. If have not test, create file with empty array. If have not tools to generate, copy it from source code in asset/sample-data/scheduler-random.json

Type:
  • string
Source:
Example
var assetDir = 'asset/sample-data'

CollectionIndex

  • Specify indexing of collection
  • It is defined by mongodb
  • This wrap keys, options parameters of db.collection.createIndex into object {keys: keys, options: options}
Type:
  • object
Source:
See:
Example
var index = {
  keys: {id: 1},
  options: {unique: true}
}

CollectionSchema

  • Specification of collection
  • It is defined by mongodb
  • This is option parameter of db.createCollection
Type:
  • object
Source:
See:
Example
var schema = {
  autoIndexId: false,
  validator: {
    $and: [
      {id: {$type: 'string', $regex: /^[a-z]{2}$/}},
      {name: {$type: 'string', $regex: /^[a-zA-Z0-9 ]{1,16}$/}}
    ]
  }
}

CollectionSpec

Type:
  • object
Properties:
Name Type Description
name string

Name of collection

schema module:database.CollectionSchema

Specification of field of collection

indexing module:database.CollectionIndex

Specification of indexing of collection

Source: