Warehouse JSON Database

6.0.0 · active · verified Wed Apr 22

Warehouse is a simple JSON-based database library for Node.js, providing a robust interface for managing data through Models, Schemas, and a flexible querying system. It is notably the underlying data store for the Hexo static site generator. The current stable version is 6.0.0, released recently in 2024, indicating active development. The project maintains a consistent release cadence with significant updates, including performance improvements and type refinements in recent major versions. Key differentiators include its focus on a structured schema-driven approach for JSON data, a powerful query engine, and strong TypeScript support, making it suitable for applications requiring local data persistence and structured access without a full-fledged SQL or NoSQL server. It has dropped support for older Node.js versions, currently requiring Node.js 18 or higher.

Common errors

Warnings

Install

Imports

Quickstart

Initializes a Warehouse database, defines a 'Post' model with a schema including a default date, and demonstrates inserting a new post.

const Database = require('warehouse');
const db = new Database();

const Post = db.model('posts', {
  title: String,
  created: {type: Date, default: Date.now}
});

Post.insert({
  title: 'Hello world'
}).then(function(post){
  console.log('New post created:', post);
}).catch(err => {
  console.error('Error creating post:', err.message);
});

view raw JSON →