Difference between revisions of "User:Saul/feathers"
From Organic Design wiki
(Created page, and added cli commands.) |
(Reverse pagination) |
||
| Line 21: | Line 21: | ||
<source lang="bash"> | <source lang="bash"> | ||
feathers generate service | feathers generate service | ||
| + | </source> | ||
| + | = Setup = | ||
| + | TBC | ||
| + | = Usage = | ||
| + | == Reverse Pagination == | ||
| + | The best way that I have found to get the latest objects in the database is to use $sort like so: | ||
| + | <source lang="javascript"> | ||
| + | app.service('messages').find({ | ||
| + | query: { | ||
| + | $limit: 10, | ||
| + | $sort: { | ||
| + | createdAt: -1 | ||
| + | } | ||
| + | } | ||
| + | }).then(res => { | ||
| + | const latest data = res.data.reverse(); | ||
| + | }; | ||
</source> | </source> | ||
Revision as of 00:22, 22 July 2018
Feathers is a lightweight framework for setting up REST API's and realtime events.
Contents
Install
CLI
Install the cli to get started with you feathers application quickly.
npm install -g @feathersjs/cli
App
To get feathers to generate the app run:
feathers generate app
Authentication
To generate a authentication method use:
feathers generate authentication
Services
Services are a way to set up the REST API for a service like messages, users, channels, ect.
feathers generate service
Setup
TBC
Usage
Reverse Pagination
The best way that I have found to get the latest objects in the database is to use $sort like so:
app.service('messages').find({
query: {
$limit: 10,
$sort: {
createdAt: -1
}
}
}).then(res => {
const latest data = res.data.reverse();
};



