Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

document.js

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

document.js

General purpose ODM supporting memory and mongo database adapters

  • 1.4.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

document.js

Circle CI
npm version
Code Climate

#Getting started

###Install it

$ npm install document.js

###Require it

var store = decidingFactor ? 'mongo' : 'memory';

Document = require('document.js/lib/index')({store: store});

###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.

Keywords

FAQs

Package last updated on 22 Sep 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc