[How to] use between operator on client side script

Say you have rent_price field[200] in property doctype, and user would like to query using range ex

[1] Get count of all properties that between 150 and 300 price range
Use array in filter and pass rent_price with >= and <=

var arr_filter=[]

arr_filter.push([‘rent_price’,‘>=’,frm.doc.price_from])
arr_filter.push([‘rent_price’,‘<=’,frm.doc.price_to])

frappe.call({
method: “frappe.client.get_list”,
args: {
doctype: “Property”,
filters: arr_filter,
fields: [“property_name”]
},
}).then(function (r) {
if (r.message) {

[2] Get route of property doctype such that list view is filtered with rent_price range
Use json in filter. JSON doesn’t allow duplicate key i.e. rent_price twice. So add one key with doctype.key

var filter = {}

filter[“Property.rent_price”] = [“>=”, frm.doc.price_from]
filter[“rent_price”] = [“<=”, frm.doc.price_to]

frappe.route_options = filter
frappe.set_route(“List”, “Property”);

With get_list one can use array and pass duplicate key and with route_options one has to use JSON and pass duplicate key by prefixing it with doctype.