redis-om-node icon indicating copy to clipboard operation
redis-om-node copied to clipboard

Redis OM Find Non-Null

Open j0hnw0rk3r opened this issue 1 year ago • 2 comments

Hi, can anyone help please? I'm try to integrate geospatial search together with filtering object keys containing null values and I only need to find all records that are 'verified'. Can someone point me into the right direction? The following code I have written seems to throw an error:

async searchNearby(longitude: number, latitude: number, radius: number = 10) {
        try {
            // Perform geospatial search
            const results = await branchesRepository.search()
                .where("verified_at").not.eq(null)
                .and('location')
                .inRadius(
                    circle => circle
                        .longitude(longitude)
                        .latitude(latitude)
                        .radius(radius)
                        .kilometers
                )
                .return.all()
            return results;
        } catch (e) {
            console.log(e);
        }
    }

j0hnw0rk3r avatar Mar 25 '24 02:03 j0hnw0rk3r

I'm pretty sure the last time I checked, you can't search on null.

KemikalGeneral avatar Mar 25 '24 10:03 KemikalGeneral

No, you can't seach by NULL (see my question https://github.com/redis/redis-om-node/issues/224 ). My workaround is writing "NULL" (the string) on it, search for this and replace the js-objects value with real null later

MR4online avatar Mar 25 '24 12:03 MR4online