One-to-Many Model and query a one-to-many relationship

This lesson is available for PRO members or as a single course purchase. Sign-in and choose a plan below.


*Enrollment provides full access to this course (and updates) for life.

Or Signup for Unlimited PRO Access

file_type_js_official firestore.js
const authorId = 'dr-seuss';

// 4. Embedded One-to-Many
const authorWithBooks = db.collection('authors').doc(authorId)


// 5. Subcollection
const books = db.collection('authors').doc(authorId).collection('books');


// 6. Root Collection, requires index
const booksFrom1971 = db.collection('books')
    .where('author', '==', authorId)
    .where('published', '>', 1971);

Q&A Chat