새소식

🏫 Framework/✨ Google Firebase

How to use the firebase like search

728x90

👉 Firebase does not support like search

👉 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

💯포스트 후원하기
반응형

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.