👉 I've been thinking a lot about this problem. As we know, the FireBase doesn't have [like search] capability. Then.. let's use jquery. Like me.
function startDatabaseQueries(searchString) {
var listeningFirebaseRefs = [];
var recentPostsRef = firebase.database().ref('yourPath').orderByChild('yourKey').limitToLast(30);
var fetchPosts = function(postsRef) {
postsRef.on('child_added', function(data) {
var name = data.val().name;
if(name.indexOf(searchString) != -1){
console.log("found!");
}else{
console.log("no data!");
}
});
};
// Fetching and displaying all posts of each sections.
fetchPosts(recentPostsRef);
// Keep track of all Firebase refs we are listening to.
listeningFirebaseRefs.push(recentPostsRef);
}
Did my writing help you?
Please press the Thumb Up button If you have any questions, please leave them in the comments