Wondering what’s next for npm?Check out our public roadmap! »

warehouseTypeScript icon, indicating that this package has built-in type declarations

4.0.0 • Public • Published

Warehouse

Build Status NPM version Coverage Status

A JSON database with Models, Schemas, and a flexible querying interface. It powers the wildly successful static site generator Hexo.

Installation

$ npm install warehouse

3.0 BREAKING CHANGE

In warehouse@3, the constructor has been changed from function declaration to class declaration or definition by class expression. Derived classes of classes defined by class declarations and class expressions must also be defined in class declaration, class expression. Anyone who created their own SchemaType will need to change.

const SchemaType = require('warehouse/schematype');
 
class MySchemaType extends SchemaType {
  constructor(name, options = {}) {
    super(name, Object.assign({ foo: 'foo' }, options));
  }
}

It changes to a class declaration or a class expression, but it does not need to deal with other than the definition of the constructor.

// It work!
 
MySchemaType.prototype.cast = function (value, data) {
  let result = SchemaType.prototype.cast.call(this, value, data);
  return result ? result : '';
}

Usage

var Database = require('warehouse');
var db = new Database();
 
var Post = db.model('posts', {
  title: String,
  created: {type: Date, default: Date.now}
});
 
Post.insert({
  title: 'Hello world'
}).then(function(post){
  console.log(post);
});

Test

$ npm test

Install

npm i warehouse

DownloadsWeekly Downloads

13,224

Version

4.0.0

License

MIT

Unpacked Size

91.6 kB

Total Files

26

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar