Hello! I am currently learning from the firestore tutorial
Initially, they guide me to populate the database with the following data:
import { collection, doc, setDoc } from "firebase/firestore";
const citiesRef = collection(db, "cities");
await setDoc(doc(citiesRef, "SF"), {
name: "San Francisco", state: "CA", country: "USA",
capital: false, population: 860000,
regions: ["west_coast", "norcal"] });
// other city data...
Later in the tutorial, there is a step to create sub-collections using the code provided below:
import { collection, doc, setDoc } from "firebase/firestore";
const citiesRef = collection(db, 'cities');
await Promise.all([
setDoc(doc(citiesRef, 'SF', 'landmarks'), {
name: 'Golden Gate Bridge',
type: 'bridge'
}),
// other landmark data...
]);
However, the above code snippet leads to an error message stating:
errors.ts:94 Uncaught FirebaseError: Invalid document reference. Document references must have an even number of segments, but cities/SF/landmarks has 3.
If anyone knows why this error is occurring, please let me know!