title: How to get last Firestore ID document
body: <p>i need help with Firestore. I have a database with a collection of Clients that have some documents named by ID (1, 2, 3..)</p>
  <p>I want a function that count the number of documents of the collection and create a new document with the value+1 (eg: the last document was 6 and i want a new document 7).</p>
  <p>This is what i have done but i don't know why it doesn't work:</p>
  <pre><code>async function pushName(name, surname) {
    const size = getID('Clients');
    const newID = (size + 1).toString();
    const docRef = firebase.firestore().collection('Clients').doc(newID);
    await docRef.set({
      FirstName: name,
      LastName: surname,
    });
    return(
      &lt;View&gt;
        &lt;Text&gt;name: {name}  &lt;/Text&gt;
        &lt;Text&gt;surname: {surname}  &lt;/Text&gt;
        &lt;Text&gt;size: {size}  &lt;/Text&gt;
        &lt;Text&gt;newID: {newID}  &lt;/Text&gt;
      &lt;/View&gt;
    );
  }
  
  async function getID(){
    
    const snapshot = await firebase.firestore().collection('Clients').get().then(function(querySnapshot) {      
      snapshot = querySnapshot.size; 
  });
    return snapshot;
  }
    
  </code></pre>
  <p>This is the output that i get:</p>
  <p><a href="https://i.stack.imgur.com/quTKx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/quTKx.png" alt="enter image description here" /></a></p>
  <p>What i do wrong? How can i do it?</p>
  <p>Thank you</p>