Source: collections.js

/**
Define region collection

@memberof module:collection
@const {module:database.CollectionSpec} REGION_COL
@example
// samples of an region correct with specification
var regionEn = {id: 'en', name: 'English'}
var regionVi = {id: 'vi', name: 'Vietnameses'}
*/
const REGION_COL = {
  name: 'region',
  schema: {
    autoIndexId: false,
    validator: {
      $and: [
        {id: {$type: 'string', $regex: /^[a-z]{2}$/}},
        {name: {$type: 'string', $regex: /^[a-zA-Z0-9 ]{1,16}$/}}
      ]
    }
  },
  indexing: {
    keys: {id: 1},
    options: {unique: true}
  }
}

/**
Define scheduler collection

@memberof module:collection
@const {module:database.CollectionSpec} SCHEDULER_COL
@example
// sample of an scheduler correct with specification
var scheduler = {
    "_id": "",
    "name": "office work",
    "tags": ["work", "company", "fulltime", "office"],
    "notes": "for guy who have busy work in office",
    "tasks": [
        {"start": "05:00", "action": "get up and run"},
        {"start": "06:00", "action": "standby"},
        {"start": "06:15", "action": "take a shower"},
        {"start": "06:30", "action": "have breakfast"},

        {"start": "07:00", "action": "go to company"},
        {"start": "07:45", "action": "prepare working"},
        {"start": "08:00", "action": "research and development"},
        {"start": "10:00", "action": "relax"},

        {"start": "12:00", "action": "have a lunch"},
        {"start": "13:00", "action": "research and development"},
        {"start": "15:00", "action": "realax"},
        {"start": "15:15", "action": "research and development"},
        {"start": "17:30", "action": "go to home"},

        {"start": "18:15", "action": "take a shower"},
        {"start": "18:30", "action": "have a dinner"},
        {"start": "21:30", "action": "sleep"}
    ]
}
*/
const SCHEDULER_COL ={
  name: 'scheduler',
  schema: {
    validator: {
      $and: [
        {'author.id': {$type: 'objectId'}},
        {'author.name': {$type: 'string', $regex: /^[a-zA-Z0-9 .-]{1,32}$/}},
        {name: {$type: 'string', $regex: /^[a-zA-Z0-9 .-]{1,32}$/}},
        {tags: {$elemMatch: {$type: 'string', $regex: /^[a-zA-Z0-9 .-]{1,16}$/}}},
        {tasks: {$elemMatch: {$type: 'object'}}},
        {'tasks.start': {$type: 'string', $regex: /^[0-2][0-3]:[0-5][0-9]$/}},
        {'tasks.name': {$type: 'string', $regex: /^[a-zA-Z0-9 .-]{1,16}$/}},
        {notes: {$type: 'string', $regex: /^.{0,1024}$/}}
      ]
    }
  },
  indexing: {
    keys: {name: 1},
    options: {unique: true}
  }
}

/**
Contains specification of collection in database

@exports collection
@author kevin leptons <kevin.leptons@gmail.com>
*/
module.exports = [REGION_COL, SCHEDULER_COL]