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.
Get Unlimited PRO Access

OR


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

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);

Questions?

Ask questions via GitHub below OR chat on Slack #questions