Skip to content
JavaScript
Branch: master
Clone or download
SukkaW refactor: use rfdc to replace lodash (#65)
* refactor: use rfdc to replace lodash
* fix: make eslint happy
Latest commit 2170bf4 Nov 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib refactor: use rfdc to replace lodash (#65) Nov 4, 2019
test Streaming Warehouse#save() (#64) Oct 28, 2019
.eslintrc.json Refacter test & Replace new Buffer() to Buffer.from() (#56) Aug 29, 2019
.gitignore test: replace istanbul with nyc (#51) Jul 27, 2019
.jsdoc.json
.travis.yml Change gh-pages deployer from script to builtin (#55) Aug 28, 2019
LICENSE
README.md Convert method definitions (#52) Sep 7, 2019
package.json refactor: use rfdc to replace lodash (#65) Nov 4, 2019

README.md

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
You can’t perform that action at this time.