Skip to content

holidayextras/jsonapi-store-mongodb

Repository files navigation

Coverage Status Build Status npm version Code Climate Dependencies Status

jsonapi-store-mongodb

jsonapi-store-mongodb is a MongoDB backed data store for jsonapi-server.

This project conforms to the specification laid out in the jsonapi-server handler documentation.

Usage

var MongoStore = require("jsonapi-store-mongodb");

jsonApi.define({
  resource: "comments",
  handlers: new MongoStore({
    url: "mongodb://localhost:27017/jsonapi",
  })
});

Features

  • Search, Find, Create, Delete, Update
  • Efficient lookups via appropriate indexes
  • Database layer filtering, pagination and sorting

Getting to Production

Getting this data store to production is really simple:

  1. Bring up your MongoDB stack.
  2. Create any indexes you may need (this is optional, this module will automatically ensure indexes exist on relationships, however you might want to add an index to an attribute you intend on querying aggressively).
  3. Deploy your code.
  4. Celebrate.

When making schema changes, deploy away and carry on. If the changes aren't backwards compatible, you may want to run a job to ensure all old (existing) records conform to the new schema. If they don't conform to the new schema, they will be dropped by jsonapi-server's validation layer.