loopback-component-filter
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

loopback-component-filter

Travis (.org) branch npm npm bundle size GitHub

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


Installation

npm i --save loopback-component-filter

Usage

Filter Repository Mixin

Change your repository parent class from DefaultCrudRepository to FilterRepositoryMixin(configs)()

Example

Change your repository from:

export class UserRepository extends DefaultCrudRepository<
    User,
    typeof User.prototype.id,
    UserRelations
> {
    // ...
}

To:

import { FilterRepositoryMixin } from "loopback-component-filter";

export class UserRepository extends FilterRepositoryMixin<
    User,
    typeof User.prototype.id,
    UserRelations
>({
    models: async (context, entities) => entities,
    where: async (context, where) => where,
    fields: async (context, fields) => fields,
})<Constructor<DefaultCrudRepository<User, string, UserRelations>>>(
    DefaultCrudRepository
) {
    // ...
}

Contributors

License

This project is licensed under the MIT license.
Copyright (c) KoLiBer (koliberr136a1@gmail.com)

Versions

Current Tags

Version History

Package Sidebar

Install

npm i loopback-component-filter

Weekly Downloads

7

Version

1.2.0

License

MIT

Unpacked Size

60.2 kB

Total Files

14

Last publish

Collaborators

  • koliber