One-to-One Step 11

This lesson is only available for PRO members. Sign-in and choose a plan below.

Monthly

$25/month
  • Unlimited course access
  • Cancel anytime
  • Slack #pro-member invite
  • AngularFirebase Survival Guide Book

Quarterly

$50/3mo
  • All monthly tier benefits
  • 33.33% discount
  • 🔥 Free Sticker

Lifetime

$300/one-time
  • All monthly tier Benefits
  • One-time payment
  • 🔥 Free sticker & 👔 T-Shirt

file_type_js_official firestore.js
const userId = 'ayn-rand';

// 1. Embedded, all data contained on single document, One-to-few

const authorWithAccount = db.collection('authors').doc(userId)

// 2. Shared Document ID
const author = db.collection('authors').doc(userId)
const account = db.collection('account').doc(userId);


// 3. Join related documents with different IDs, 
const getAccount = async (userId) => {
    const snapshot = await db.collection('authors').doc(userId).get();
    const user = snapshot.data();

    return db.collection('accounts').doc(user.accountId)
}

Q&A Chat