a complex data builder that uses simple definitions


stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
63Apr 24, 2021Mar 26, 2017Minified + gzip package size for @onehilltech/dab in KB



A complex data builder that uses simple definitions

npm version Build Status Dependencies Coverage Status


  • Build data models from data definitions to seed databases
  • Compute data values based on other parts of the data model
  • Supports MongoDB via Mongoose
  • Plays nicely with faker.js

Getting Started

First, define your data model.

// demo.js

const dab = require ('@onehilltech/dab');

var data = {
  users: [
    {first_name: 'John', last_name: 'Doe'},
    {first_name: 'Jane', last_name: 'Doe'}
  family: [
    {user1: dab.ref ('users.0'), user2: dab.ref ('users.1'), relationship: 'spouse'}

Direct Integration

Next, build the data model.

// client.js

const backend = require ('@onehilltech/dab-mongodb');

dab.build (data, { backend }).then (models => {
  // model is the final data model  

You must provide a target backend for the build. In the example above, the target backend is MongoDB. The result will be a data model where all objects have an _id property, and all computed values are resolved. The returned model can also seed a MongoDB database. Each collection in the data model will contain instances of Mongoose documents.

// client.js

dab.seed (models, conn, { backend }).then (models => {
  // models will be MongoDB models

Command-line Usage

It is possible to generate a dab model from the command-line:

dab build <dabfile>

You can even seed a database from the command-line:

dab seed --connection <CONNECTION> <dabfile>

Next Steps

See our Wiki for more details on using dab.

Need help? Contact us

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.