Basically, what I want is to search data by username (which is displayName Field)

Below is how my profiles collection is like.

enter image description here

async localUsers(){       
        await authorizePromise;
        const {radius} = UserStateService.getState();'Getting local users with radius', radius);

        const opts = {

        const hashes = proximityhash.createGeohashes(opts);

        const profiles = firebase.firestore().collection('profiles');

        let queries = => rangeQueryParams(hash))
            .map(range => profiles.where('hash', '>=', range.start).where('hash', '<', range.end).get());

        const ME = UserProfileStore.getProfile();

        const results = await Promise.all(queries);

        return []
            .concat( =>
            .filter(_ => !UserProfileStore.isForbiddenRelationship( || ===
            .filter(_ => !== false)
            .sort((a, b) =>{
                return['lastSeen'] -['lastSeen'];

So above localUsers function here fetches data from 'profiles' collection and where this line where('hash', '>=', range.start).where('hash', '<', range.end). fetches data on the basis of hash Field.

But I want to do is to fetch data on the basis of displayName Field and change the queries variable like below.

 let queries = => rangeQueryParams(hash))
            .map(range => profiles
            .where('hash', '>=', range.start).where('hash', '<', range.end)
            .startAt(username)        // username is the value user enters
            .endAt(username + '\uf8ff')

And the above queries doesn't return anything.

I know the code seems complicated, it is for me too because I'm redesigning this application which is already on Google Play.

0 Answers