@bleco/oso-juggler
TypeScript icon, indicating that this package has built-in type declarations

0.5.10 • Public • Published

@bleco/oso-juggler

An oso data filtering adapter for loopback juggler orm

Usage

Define a repository factory for JugglerAdapter. for example:

import {RepositoryFactory} from '@bleco/oso-juggler';
import {Context} from '@loopback/context';
import {juggler} from '@loopback/repository';
import {EntityClass, QueryEnhancedCrudRepository} from 'loopback4-query';

function repositoryFactory<T extends Entity = Entity>(context: Context, dsName: string): RepositoryFactory<T> {
  return async modelName => {
    const ds = await context.get<juggler.DataSource>(`datasources.${dsName}`);
    const entityClass = await context.get<EntityClass<T>>(`models.${modelName}`);
    return new QueryEnhancedCrudRepository(entityClass, ds);
  };
}

Create juggler adapter with the factory:

import {JugglerAdapter} from '@bleco/oso-juggler';

const adapter = new JugglerAdapter(repositoryFactory(context, 'db'));

const oso = new Oso();
oso.setDataFilteringAdapter(adapter);

Package Sidebar

Install

npm i @bleco/oso-juggler

Weekly Downloads

2

Version

0.5.10

License

MIT

Unpacked Size

31.1 kB

Total Files

19

Last publish

Collaborators

  • towyuan