Skip to content

Commit f34cbf8

Browse files
author
KoLiBer
committed
fix: change README
1 parent 0337f3b commit f34cbf8

File tree

1 file changed

+38
-48
lines changed

1 file changed

+38
-48
lines changed

README.md

+38-48
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,64 @@
11
# loopback-component-filter
22

3-
[![Build Status](https://travis-ci.com/loopback4/loopback-component-filter.svg?branch=master)](https://travis-ci.com/loopback4/loopback-component-filter)
3+
![checks](https://img.shields.io/github/checks-status/loopback4/loopback-component-filter/next)
4+
![npm latest](https://img.shields.io/npm/v/loopback-component-filter/latest)
5+
![npm next](https://img.shields.io/npm/v/loopback-component-filter/next)
6+
![license](https://img.shields.io/github/license/loopback4/loopback-component-filter)
47
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Floopback4%2Floopback-component-filter.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Floopback4%2Floopback-component-filter?ref=badge_shield)
5-
![Travis (.org) branch](https://img.shields.io/travis/loopback4/loopback-component-filter/master)
6-
![npm](https://img.shields.io/npm/v/loopback-component-filter)
7-
![npm bundle size](https://img.shields.io/bundlephobia/min/loopback-component-filter)
8-
![GitHub](https://img.shields.io/github/license/loopback4/loopback-component-filter)
98

109
Using this simple extension you can filter models in repository level.
1110

12-
---
13-
1411
## Installation
1512

13+
Use the package manager [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) to install `loopback-component-filter`.
14+
1615
```bash
1716
npm i --save loopback-component-filter
1817
```
1918

20-
---
21-
2219
## Usage
2320

24-
### Filter Repository Mixin
21+
Follow these steps to add `Filter` extension to your loopback4 application:
2522

26-
Change your repository parent class from `DefaultCrudRepository` to `FilterRepositoryMixin(configs)()`
23+
- Change your repository parent class from `DefaultCrudRepository` to `FilterRepositoryMixin(configs)()`
2724

28-
#### Example
25+
```ts
26+
// Old
27+
export class UserRepository extends DefaultCrudRepository<
28+
User,
29+
typeof User.prototype.id,
30+
UserRelations
31+
> {
32+
// ...
33+
}
2934

30-
Change your repository from:
35+
// New
36+
import { FilterRepositoryMixin } from "loopback-component-filter";
3137

32-
```ts
33-
export class UserRepository extends DefaultCrudRepository<
34-
User,
35-
typeof User.prototype.id,
36-
UserRelations
37-
> {
38-
// ...
39-
}
40-
```
38+
export class UserRepository extends FilterRepositoryMixin<
39+
User,
40+
typeof User.prototype.id,
41+
UserRelations
42+
>({
43+
models: async (context, entities) => entities,
44+
where: async (context, where) => where,
45+
fields: async (context, fields) => fields,
46+
})<Constructor<DefaultCrudRepository<User, string, UserRelations>>>(
47+
DefaultCrudRepository
48+
) {
49+
// ...
50+
}
51+
```
4152

42-
To:
43-
44-
```ts
45-
import { FilterRepositoryMixin } from "loopback-component-filter";
46-
47-
export class UserRepository extends FilterRepositoryMixin<
48-
User,
49-
typeof User.prototype.id,
50-
UserRelations
51-
>({
52-
models: async (context, entities) => entities,
53-
where: async (context, where) => where,
54-
fields: async (context, fields) => fields,
55-
})<Constructor<DefaultCrudRepository<User, string, UserRelations>>>(
56-
DefaultCrudRepository
57-
) {
58-
// ...
59-
}
60-
```
61-
62-
---
53+
## Contributing
6354

64-
## Contributors
55+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
6556

66-
- [KoLiBer](https://www.linkedin.com/in/mohammad-hosein-nemati-665b1813b/)
57+
Please make sure to update tests as appropriate.
6758

6859
## License
6960

70-
This project is licensed under the [MIT license](LICENSE.md).
61+
This project is licensed under the [MIT](LICENSE.md).
7162
Copyright (c) KoLiBer (koliberr136a1@gmail.com)
7263

73-
74-
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Floopback4%2Floopback-component-filter.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Floopback4%2Floopback-component-filter?ref=badge_large)
64+
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Floopback4%2Floopback-component-filter.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Floopback4%2Floopback-component-filter?ref=badge_large)

0 commit comments

Comments
 (0)