Showing posts from November, 2018

partial search with firestore

You can provide partial search [ type ahead facility ] with firestore. It's not that much streight forward and also not feasible in case of large amount of data that has to support the partial search.

Here is just a sample of how you provide partial search with firestore.

Logic behind the search is a custom kind of indexing that enables partial search for us. You need to create a collection of documents called indexes which contains indexes generated for the fields you want to search over.

First reqirement is to create every possible partial search strings.
Below function returns array of the possible indexes generate after chopping out input string character by character.

/* storing searchabel fields */function _chopped_object(iString) { var searchables = {} for (i = 0; i < iString.length; i++) { var string_part = iString.substr(0, iString.length - i) searchables[string_part] = true } return searchables }
Output of _chopped_object(manish) will be,

manish :true

Creating nested documents in firestore

Firestore returning no records yet, I see them in consoleCollection not retuning any element.... ... 
You might facing issues written above. Then it might be this case.

You might getting empty response in this kind of query though there are elements in firestore.

db.collection(collection1).doc(doc1) .collection(collection2).doc(doc2) .collection(collection3).get() .then( function (querySnapshot) { querySnapshot.forEach(function (doc) { console.log(, " = ",; } )
I face the same problem. Though data was stored sucessfully ( I was guessing, which was wrong actully ).  To verify that your data is not stored as you expceted you can do check this.

If key of your data is in italic font then your data is not stored or is marked as deleted [ that was happening in my case ]. See in image.

Now you might thinking, that I have created element and  not deleted it then why it's showing as deleted.

Truth is that if you want to create neste…

Upload Files to Firebase Storage with dropzone.js

Almost every file uploader I found on web are expecting url to where we want to upload file. If you are using firebase storage then you will find this awkward as you don't have any rest url where you have to upload file

Instead, file upload handled by firestore library firebase-storage.

After certain effort I found a way to use dropzone.js with firebase storage. Here is some snippet of code which you may find useful, If you are in the same situation as I am.

This both function are in same file

Dropzone configuration.. ( in index.js )
var myDropzone =new Dropzone("form#dropzone", { // Make the whole body a dropzone url:'/', addRemoveLinks:true, method:'put', chunking:true, forceChunking:true, autoQueue:false, autoProcessQueue:false }); myDropzone.autoDiscover =false; myDropzone.on("addedfile", function(file) { var rea…