Firebase Swift - How to create a child and add its id to another ref property?
<p>As described <a href="https://stackoverflow.com/questions/38868947/firebase-database-structure-need-advice">here</a>, I'd like to store Book objects in a separate ref and store its id value inside <code>books</code> property of <code>User</code></p>

<pre><code>Users:
user_id:121jhg12h12
  email: "john@doe.com"
  name: "John Doe"
  profile_pic_path: "https://...".
  language: "en"
  exp_points: 1284
  friends: [user_id]
  books: [[book_id, status, current_page, start_date, finish_date]]
  badges: [[badge_id, get_date]]

Books:
book_id: 3213jhg21
  title: "For whom the bell tolls"
  author: "Ernest Hemingway"
  language: "en"
  pages_count: 690
  ISBN: "21hjg1"
  year: 2007
</code></pre>

<p>Whenever I add a book inside the app</p>

<pre><code>self.ref!.child("Books").childByAutoId().setValue(["title": arrayOfNames[0] as! NSString, "author": arrayOfNames[1] as! NSString , "pages_count":arrayOfNames[2] as! NSString])
</code></pre>

<p>The book object is created in Books ref, but I'd like to add its id to the User's books array of user right away. </p>

<p>Can it be done in some nifty way, instead of querying the book, retrieve its ID and add it to the array? </p>

<p>If no, what's the proper way o querying the object id that has been just created?</p>

<p>Maybe I should not use AutoId mode and create unique Id for each object by myself in app?</p>