A REST plugin for netiam
npm i -S netiam netiam-contrib-rest
netiam({plugins})
.rest({model: User})
.json()
To reduce the number of HTTP requests, you can embed related documents within
the response object. You can do so, by utilizing the include
parameter.
GET /articles?include=comments
Youc an also include more than one document at the same time.
GET /articles?include=comments,links
There is also support for deeply nested documents and documents on the same branch.
GET /articles?include=comments.author.profile,comments.author.image
This plugin does support transactions via sequelize cls
namespaces.
However, it does not enforce transactions as you might use a database engine w/o
any support for transactions.
How to
// test/utils/db.js
import Sequelize from 'sequelize'
import cls from 'continuation-local-storage'
import uuid from 'uuid'
const namespace = cls.createNamespace(uuid.v4())
Sequelize.cls = namespace
export const db = new Sequelize('database', 'username', 'password', {
…
})