Dynamic teams modules
Here is the mapping of service methods to REST API calls. The “messages” services could be any user defined service.
Service method | HTTP method | Path |
.find() | GET | /api/v1/myteamdomain/messages |
.get() | GET | /api/v1/myteamdomain/messages/123 |
.create() | POST | /api/v1/myteamdomain/messages |
.update() | PUT | /api/v1/myteamdomain/messages/123 |
.patch() | PATCH | /api/v1/myteamdomain/messages/123 |
.remove() | DELETE | /api/v1/myteamdomain/messages/123 |
find
Retrieves a list of all matching resources from the service
GET /api/v1/myteamdomain/messages?status=read&user=10
Will call zoolo('messages').find({ query: { status: 'read', user: '10' } })
on the server.
If you want to use any of the built-in find operands ($le, $lt, $ne, $eq, $in, etc.) the general format is as follows:
GET /api/v1/myteamdomain/messages?field[$operand]=value&field[$operand]=value2
For example, to find the records where field status is not equal to active you could do
GET /api/v1/myteamdomain/messages?status[$ne]=active
The find API allows the use of $limit, $skip, $sort, and $select in the query. These special parameters can be passed directly inside the query object:
`// Find all messages that are read, limit to 10, only include text field. {"read":"1", "$limit":10, "$select": ["name"] } } // JSON
GET /api/v1/myteamdomain/messages?read=1&$limit=10&$select[]=text // HTTP`
get
Retrieve a single resource from the service.
GET /api/v1/myteamdomain/messages/123
Will call zoolo('messages').get(123, {})
on the server.
GET /api/v1/myteamdomain/messages/1?fetch=all
Will call zoolo('messages').get(1, { query: { fetch: 'all' } })
on the server.
create
Create a new resource with data
which may also be an array.
POST /api/v1/myteamdomain/messages { "text": "I really have to iron" }
Will call messages.create({ "text": "I really have to iron" }, {})
on the server.
POST /messages [ { "text": "I really have to iron" }, { "text": "Do laundry" } ]
Note: With a database adapters the multi option has to be set explicitly to support creating multiple entries.
update
Completely replace a single or multiple resources.
PUT /api/v1/myteamdomain/messages/123 { "text": "I really have to do laundry" }
Will call zoolo('messages').update(123, { "text": "I really have to do laundry" }, {})
on the server. When no id
is given by sending the request directly to the endpoint something like:
PUT /api/v1/myteamdomain/messages?complete=false { "complete": true }
Will call zoolo('messages').update(null, { "complete": true }, { query: { complete: 'false' } })
on the server.
ProTip: update is normally expected to replace an entire resource which is why the database adapters only support patch for multiple records.
patch
Merge the existing data of a single or multiple resources with the new data
.
PATCH /api/v1/myteamdomain/messages/123 { "read": true }
Will call zoolo('messages').patch(123, { "read": true }, {})
on the server. When no id
is given by sending the request directly to the endpoint something like:
PATCH /api/v1/myteamdomain/messages?complete=false { "complete": true }
Will call zoolo('messages').patch(null, { complete: true }, { query: { complete: 'false' } })
on the server to change the status for all read messages.
Note: With a database adapters the multi option has to be set to support patching multiple entries.
This is supported out of the box by the Feathers database adapters
remove
Remove a single or multiple resources:
DELETE /api/v1/myteamdomain/messages/123?cascade=true
Will call zoolo('messages').remove(123, { query: { cascade: 'true' } })
.
When no id
is given by sending the request directly to the endpoint something like:
DELETE /api/v1/myteamdomain/messages?read=true
Will call messages.remove(null, { query: { read: 'true' } })
to delete all read messages.
Note: With a database adapters the multi option has to be set to support patching multiple entries.
Last updated