JSPM

  • Created
  • Published
  • 0
  • Score
    100M100P100Q63961F
  • License MIT

General purpose ODM supporting memory and mongo database adapters

Package Exports

  • document.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (document.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

document.js

Circle CI
npm version

#Getting started

###Install it

$ npm install document.js

###Require it

var Document = require('document.js');

###Use it

Channel = Document.progeny('Channel', {
}, {
  classMethods: {
    fields: {
      String: { slug: 's', name: 'n', token: 't' },
      Date: { firstMessageAt: 'fma' },
      Integer: { keepAlive: 'ka', buffered: 'b', capped: 'c' },
      Object: { info: 'i' }
    },
    belongsTo: ['user'],
    // hasMany: ['messages'], TODO
    allow: ['name', 'token', 'userId', 'firstMessageAt', 'buffered', 'capped'],
    validate: {
      presence: ['name', 'userId'],
      format: { slug: /^#\w{4,16}/ },
      custom: [
        function() { return Object.keys(this.get('info')).length > 0 }
      ]
    },
    beforeCreate: [
      function() {
        this.set('token', '{{random token generator}}');
      }
    ]
  }
});

For the full API see the document definition docs.