redis / redis-om-node

Object mapping, and more, for Redis and Node.js. Written in TypeScript.
MIT License
1.18k stars 80 forks source link

Redis OM Find Non-Null #232

Open j0hnw0rk3r opened 7 months ago

j0hnw0rk3r commented 7 months ago

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);
        }
    }
KemikalGeneral commented 7 months ago

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

MR4online commented 7 months ago

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