Boldijar Paul
Boldijar Paul

Reputation: 5495

Firebase database rest simple query not working

I'm trying just to filter some data in firebase database.

ex: Doing a get request on

https://projectname.firebaseio.com/logs.json

Will give me the next response:

"-KvW0jtLcytZnzIXonK6": {
    "exception": "NPE",
    "level": "Verbose",
    "message": "A message example",
    "tag": "MainActivity",
    "timestamp": "50",
    "user": "paul"
},
"-KvW0f7o-SP33k5Icx5d": {
    "exception": "NPE",
    "level": "Verbose",
    "message": "A message example",
    "tag": "MainActivity",
    "timestamp": "210",
    "user": "paul"
},
"-KvW0dPwp9eCSJqTcAWS": {
    "exception": "NPE",
    "level": "Verbose",
    "message": "A message example",
    "tag": "MainActivity",
    "timestamp": "100",
    "user": "paul"
},

I just want to be able to filter by the timestamp. Example: * query for all logs where the timestamp is greater than 90

I've tried this with

https://projectname.firebaseio.com/logs.json?orderBy="timestamp"&startsAt=90

But the result is not filtered.

Upvotes: 0

Views: 107

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598708

I see two problems:

  1. Your timestamp is stored as a string, so you need to pass the value for the query as a string too.
  2. The parameter name is startAt, not startsAt (as ittus said in their comment).

So:

https://projectname.firebaseio.com/logs.json?orderBy="timestamp"&startAt="90"

Upvotes: 1

Related Questions