Loopback filter like case insensitive

How to user case insensitive where filter in loopback with postgresql.
I have trued using

pattern = new RegExp('.*'+data+'.*', "i")

but not working.
My code is

searchUsersAppointment(data): void {
    let cpr = /^d+$/.test(data);
    let pattern = new RegExp('.*'+data+'.*', "i");
    let query = {};
    if(cpr){
        query = {where: {CPR: {like: data} } };
    }else{
        query = {where: {firstName: {like: pattern} } };
    }
    this.patientDetailsApi.find(query).subscribe(searchDetails => {
        this.searchDetails = searchDetails;
    })
}

Can any one help me to fix this issue.

Source: AngularJS