Contribute to this guide

guidejhbhkk

ll

op: các kiểu so sánh (equal, contains, between, in, greater, less, greaterEqual, lessEqualbeginWith, endWith) tương ứng với từng kiểu theo chuẩn "mysql"

type: lựa chọn kết hợp là nhiều tiêu chí so sánh "and", "or"

field: tên định nghĩa trong CSDL

value: giá trị so sánh với trường dữ liệu (field) theo kiểu (op)

Chi tiết 

equal: "="

contains: "like"

between: "between"

greater: ">"

less: "<"

greaterEqual: ">="

lessEqual: "<="

beginWith: "like"

endWith: "like"

in: "in" 

Ví dụ

Giả sử có bảng lưu danh sách khách hàng với cấu trúc và dữ liệu như sau:

[

   {"fullname": "Nguyễn Văn Anh", "username": "anhnv@tafalo.com", "birthdate": "1980-02-20", "created_at": "2020-12-01", "address": "Từ liêm, Hà Nội", "mobile": "098765432", "gender": "male"},

{"fullname": "Trần Thị Miến", "username": "anhnv@tafalo.com", "birthdate": "1989-12-20", "created_at": "2015-02-11", "address": "Vĩnh Phúc", "mobile": "0192938476", "gender": "female"}

]

1, Cần tìm khách hàng là nữ

{filterRules: [{"field":"gender","value":"female","op":"equal"}]}

Kết quả:  [{"fullname": "Trần Thị Miến", "username": "anhnv@tafalo.com", "birthdate": "1989-12-20", "created_at": "2015-02-11", "address": "Vĩnh Phúc", "mobile": "0192938476", "gender": "female"}]

2. Cần tìm khách hàng có ngày sinh lớn hơn 1985

{filterRules: [{"field":"birthdate","value":"1986-01-01","op":"greaterEqual"}]}

3. Cần tìm khách hàng là nữ và có ngày sinh lớn hơn 1985

{filterRules: [{"field":"birthdate","value":"1986-01-01","op":"greaterEqual"},{"field":"gender","value":"female","op":"equal"}

], "type": "and"}

 

kv61itdqd8qh1pof
TinTuc
kv6e2scfgjcxlcwz