title: Saving custom datatypes in Firebase Firestore
body: <p>I have this class structure that I need to store in Firebase Firestore.</p>
  
  <pre class="lang-java prettyprint-override"><code>class A {
   int i = 3;
  }
  class B {
   A xa = new A();
   A ya = new A();
  }
  class C {
   B b = new B();
   String name = "hi";
  }
  
  C c1 = new C();
  </code></pre>
  
  <p>I want to store the value <code>c1</code> in a document.<br> 
  One way of doing so is like this.</p>
  
  <pre class="lang-js prettyprint-override"><code>db.collection("Cs").document("c1").set({
    "b": {
      "xa": {
        "i": 3,
      },
      "ya": {
        "i": 3,
      },
    },
    "name": "hi",
  });
  </code></pre>
  
  <p>And another way of doing it.</p>
  
  <pre class="lang-js prettyprint-override"><code>ref1 = db.collection("Cs").document("c1");
  ref1.set({"name": "hi"});
  ref2 = ref1.collection("B").document("b").collection("A");
  ref2.document("xa").set({"i": 3});
  ref2.document("xb").set({"i": 3});
  </code></pre>
  
  <p>Can anyone tell me what is the best way of doing this. If there is any other better way of doing this, can you please state that?</p>