Confusion About Firebase startAt ()

I am trying to make an android application with firebase, I want to use the search function on firebase using startAt(). But the result confuses me.

I have data with such a database.

{
  "siswa" : {
    "100" : {
      "id" : 100,
      "nama" : "Sucipto"
    },
    "101" : {
      "id" : 101,
      "nama" : "Tomo"
    },
    "102" : {
      "id" : 102,
      "nama" : "Fitri"
    },
    "103" : {
      "id" : 103,
      "nama" : "Sumini"
    },
    "104" : {
      "id" : 104,
      "nama" : "Eko"
    },
    "106" : {
      "id" : 106,
      "nama" : "Sulastri"
    }
  }
}

My request example

// Setup Firebase
final FirebaseDatabase database = FirebaseDatabase.getInstance();
// Firebase siswa ref
final DatabaseReference siswaRef = database.getReference("siswa");
// Query
Query suciptoQuery = siswaRef.orderByChild("nama").startAt("Sucipto");

Result:

 D/Query Sucipto: Nama : Sucipto
 D/Query Sucipto: Nama : Sulastri
 D/Query Sucipto: Nama : Sumini
 D/Query Sucipto: Nama : Tomo

I will try another test request

Query suciptoQuery = siswaRef.orderByChild("nama").startAt("Su");

Result: Same as above.

Another request:

Query suciptoQuery = siswaRef.orderByChild("nama").startAt("Tomo");

or

Query suciptoQuery = siswaRef.orderByChild("nama").startAt("To");

Result:

D/Query Sucipto: Nama : Tomo

I am looking for this topic on SO, but still have no solution.

+4
source share
1 answer

I checked startAt () docs and that logic is pretty confusing. But if I understand correctly (yes, I’m not quite sure, but I’m going to send it forward, this may help).

" Sucipto", , , /, , . , , , Eko Fitri , "S" 'F' 'E'.

, , , "Sucipta" . , startAt() - "Sucipto", "Sucipta" , "Sucipta" ( alpahabetically first (a, b, c.... ) , ).

, , Firebase . .

+1

All Articles