3.4.1 • Published 7 months ago

spring-filter-ng v3.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Spring-filter-ng

A filter builder to manage Spring Filter library for Angular application.

Getting started

Install Spring filter ng

npm install spring-filter-ng

Angular Support

AngularSpring-filter-ngStatus
143.xActive
12/131.x+-

Usage

import {SpringFilter, SpringFilterUtils } from 'spring-filter-ng';
...

public searchByFilter() {

  //initialize filter
  const filterBuild = new SpringFilter().build(); 
  
  //Build query
  const filter = filterBuild.equals("email","example@mail.it").value;
  
  //Set parametrs for angular http.
  const options = SpringFilterUtils.setOptions(value);
  
  //Fetch datas.
  this.fetchApiService.getStuffsByFilter(options)......
  

}

Example

Considering an employee

interface Employee {
  id: number;
  firstName: string;
  lastName: string;
  birthDate: string;
  maritalStatus: string;
  salary: number;
  manager: Employee;
  staff: Employee[];
}

 
1. If you want to know the employees who receive a salary greater than 3000:

 const filter = SpringFilter.new().greaterThen("employee.salary", 3000).value;
 
2. If you want to know the employees who have marital status divorced or separated and have 
   at least two stuff members or are not manager:

 const filter = SpringFilter.new().append("maritalStatus").in("divorced", "separated")
    .and(SpringFilter.new().greaterThan(springFilter.instance().size("staff"), 2).or("manager").isNotNull()).value;
    

Utils

It is possbile to use utils method from SpringFilterUtils .

Compact expressions.

It is possible to use expressions more compact in this way:

const filter = new SpringFilter()
    .build() 
    .orLike("firstName", SpringFilterUtils.likeRight(value))
    .orLike("lastName", SpringFilterUtils.likeRight(value))
    .andEquals("id", value).value
 

Love spring-filter-ng ? Give to repo a star :star:.

3.4.0

7 months ago

3.4.1

7 months ago

3.3.1

8 months ago

3.3.0

8 months ago

3.2.2

1 year ago

3.2.1

1 year ago

3.2.0

1 year ago

3.0.2

1 year ago

3.1.0

1 year ago

3.0.1

1 year ago

3.2.4

1 year ago

3.2.3

1 year ago

3.0.0

1 year ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago