spool-tapestries

Tapestries Spool. This spool provides the tapestry interface, which
other spools such as spool-sequelize implement,
as well as a suite of tests that Tapestry implementations should pass.

What are Tapestries?
Tapestries automatically generate easy-to-use RESTful endpoints for your models.
Install
$ npm install @fabrix/spool-tapestries --save
export const main {
spools: [
require('@fabrix/spool-tapestries').TapestriesSpool
]
}
export const tapestries = {
controllers: {
method: '*',
ignore: [ ]
},
models: {
options: {
defaultLimit: 100,
watch: false,
populate: true
},
actions: {
create: true,
find: true,
update: true,
destroy: true,
createAssociation: true,
findAssociation: true,
updateAssociation: true,
destroyAssociation: true
}
},
prefix: '/api/v1'
}
API
api.services.TapestryService
The purpose of TapestryService
is to transform and forward queries to the datastore.
create (modelName, values, [options])
param |
required? |
description |
example |
modelName |
Yes |
The name of the model to create (in api.models ) |
User |
values |
Yes |
An object containing the values of the record to create |
{ username: 'admin' } |
options |
No |
Datastore-specific options |
|
find (modelName, criteria, [options])
param |
required? |
description |
example |
modelName |
Yes |
The name of the model to search for (in api.models ) |
User |
criteria |
Yes |
An object containing the query criteria |
{ username: 'admin' } |
options |
No |
Datastore-specific options |
|
update (modelName, criteria, values, [options])
param |
required? |
description |
example |
modelName |
Yes |
The name of the model to create (in api.models ) |
User |
criteria |
Yes |
An object containing the query criteria |
{ username: 'admin' } |
values |
Yes |
An object containing the values to update |
{ username: 'tjwebb' } |
options |
No |
Datastore-specific options |
|
destroy (modelName, criteria, options)
param |
required? |
description |
example |
modelName |
Yes |
The name of the model to create (in api.models ) |
User |
criteria |
Yes |
An object containing the query criteria |
{ username: 'admin' } |
values |
Yes |
An object containing the values to update |
{ username: 'tjwebb' } |
options |
No |
Datastore-specific options |
|
createAssociation (parentModelName, parentId, childAttributeName, values, [options])
param |
required? |
description |
example |
parentModelName |
Yes |
The name of the parent model |
User |
parentId |
Yes |
The id of the parent model |
1 |
childAttributeName |
Yes |
The name of the attribute to create and associate with the parent |
roles |
values |
Yes |
An object containing the values to create |
{ name: 'adminRole' } |
options |
No |
Datastore-specific options |
|
findAssociation (parentModelName, parentId, childAttributeName, criteria, [options])
param |
required? |
description |
example |
parentModelName |
Yes |
The name of the parent model |
User |
parentId |
Yes |
The id of the parent model |
1 |
childAttributeName |
Yes |
The name of the attribute to create and associate with the parent |
roles |
criteria |
Yes |
An object containing the criteria to search on, or an id |
{ name: 'adminRole' } |
options |
No |
Datastore-specific options |
|
updateAssociation (parentModelName, parentId, childAttributeName, criteria, values, [options])
param |
required? |
description |
example |
parentModelName |
Yes |
The name of the parent model |
User |
parentId |
Yes |
The id of the parent model |
1 |
childAttributeName |
Yes |
The name of the attribute to create and associate with the parent |
roles |
criteria |
Yes |
An object containing the criteria to search on, or an id |
{ name: 'adminRole' } |
values |
Yes |
An object containing the values to update |
{ name: 'adminRole' } |
options |
No |
Datastore-specific options |
|
destroyAssociation (parentModelName, parentId, childAttributeName, criteria, [options])
param |
required? |
description |
example |
parentModelName |
Yes |
The name of the parent model |
User |
parentId |
Yes |
The id of the parent model |
1 |
childAttributeName |
Yes |
The name of the attribute to destroy and dissociate from the parent |
roles |
criteria |
Yes |
An object containing the criteria to search on, or an id |
{ name: 'adminRole' } |
options |
No |
Datastore-specific options |
|
api.controllers.TapestryController
The purpose of the TapestryController
is to transform and forward requests to the TapestryService
.