Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
330 views
in Technique[技术] by (71.8m points)

Firebase Search Query startAt endAt

I am having a problem when querying for search process with Firebase Rest api. I use the startAt and endAt parameters for the first and last search, but it still doesn't list it.

https://myprojectdemo.firebaseio.com/posts.json?orderBy="title"&startAt="Car"&endAt="Caruf8ff"&print=pretty

I make a GET request this way.

"-WE2QEYJx8gaOUkOsvWkV": {
  "title" : "Red Car",
  "category" : "Other" 
},
"-WE2KSBJx8gaOUkOsvWkV": {
  "title" : "White Car",
  "category" : "Other" 
}

I have an output like above. There are two shipments titled White Car and Red Car. When I search for car, I want both of them to come out. Where am I making a mistake?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It looks like what you're trying to do is find strings the end with some substring. You can only search for strings that begin with some substring. Realtime Database does not support substring queries in any other way except for string prefixes.

If you want to be able to search for items that are cars, consider adding another piece of data to each child indicating that it is a car type object, and use that to filter your result set. Using the title as you have it now will not work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...