# warehouse

> Simple JSON-based database

Latest version **7.0.0** (published 2026-08-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install warehouse
pnpm add warehouse
yarn add warehouse
bun add warehouse
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 7.0.0 |
| Published | 2026-08-13 |
| First published | 2013-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 8 |
| Unpacked size | 258.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 206 |
| Author | Tommy Chen |
| Maintainers | abnerchou, tommy351, jlhwung, tomap, yoshinorin |
| Keywords | database, json, db |

## Links

- npm: https://www.npmjs.com/package/warehouse
- Repository: https://github.com/hexojs/warehouse
- Homepage: https://github.com/hexojs/warehouse#readme
- Issues: https://github.com/hexojs/warehouse/issues
- npm.io page: https://npm.io/package/warehouse

## Dependencies (8)

- [rfdc](https://npm.io/package/rfdc.md) ^1.3.0
- [nanoid](https://npm.io/package/nanoid.md) ^3.3.7
- [bluebird](https://npm.io/package/bluebird.md) ^3.7.2
- [hexo-log](https://npm.io/package/hexo-log.md) ^4.0.1
- [through2](https://npm.io/package/through2.md) ^4.0.2
- [jsonparse](https://npm.io/package/jsonparse.md) ^1.3.1
- [graceful-fs](https://npm.io/package/graceful-fs.md) ^4.2.10
- [is-plain-object](https://npm.io/package/is-plain-object.md) ^5.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 7.0.0 (latest) — 2026-08-13
- 6.0.0 — 2025-01-17
- 5.0.1 — 2024-01-14
- 5.0.0 — 2022-11-09
- 4.0.2 — 2022-07-29
- 4.0.1 — 2022-04-14
- 4.0.0 — 2020-05-19
- 3.0.2 — 2020-01-13
- 3.0.1 — 2019-10-12
- 3.0.0 — 2019-09-26
- 2.2.0 — 2016-02-14
- 2.1.3 — 2016-02-07
- 2.1.2 — 2016-01-09
- 2.1.1 — 2015-12-01
- 2.1.0 — 2015-11-30
- … 33 more at https://npm.io/package/warehouse/versions

## README

# Warehouse

![Tester](https://github.com/hexojs/warehouse/workflows/.github/workflows/ci.yml/badge.svg)
![Pages Deployer](https://github.com/hexojs/warehouse/workflows/.github/workflows/pages.yml/badge.svg)
[![NPM version](https://badge.fury.io/js/warehouse.svg)](https://www.npmjs.com/package/warehouse)
[![Coverage Status](https://coveralls.io/repos/github/hexojs/warehouse/badge.svg?branch=master)](https://coveralls.io/github/hexojs/warehouse?branch=master)

A JSON database with Models, Schemas, and a flexible querying interface. It powers the wildly successful static site generator [Hexo](https://hexo.io).

## Installation

``` bash
$ 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.

``` js
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.

``` js
// It work!

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

## Usage

``` js
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);
});
```

+ [API documentation](https://hexojs.github.io/warehouse/)
+ [Examples of `Model`, `Schema`, and `SchemaType`](https://github.com/hexojs/hexo/tree/master/lib/models)
+ [More examples in `./test/scripts`](./test/scripts)

## Test

``` bash
$ npm test
```

---
_Source: https://npm.io/package/warehouse · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
