How to auto increment a Cloud Firestore document existing number field id #9

Learn How to auto increment a Cloud Firestore document existing number field id. In this chapter, we will learn how to insert a data with an auto increment id and using it an unique id instead of default Push ID provided by Firebase. Consider the following example: You have a Student collection and it has data with auto incremented value. When you insert the next, it should have id = 4. Now Firebase doesnot provide anything related to this autoincrement feature. It has only unique id generated by its logic. So we will do some manual coding for it. Now, you have the easy solution is to get the total size of the list of documents +1. Consider the following code $newid = app('firebase.firestore')->database()->collection('Student') ->documents()->size()+$i; //Insert new record app('firebase.firestore')->database()->collection('Student') ->document($ne...