Linea
Purpose
The Linea collection defines the structure of product lines within a brand.
Its purpose is to group multiple glasses models (Occhiale) under a specific line, with metadata such as descriptions, images, and brand references.
Document schema
{
"brand": "reference",
"descrizione": "string",
"descrizione_en": "string",
"listaRefsOcchiale": ["reference"],
"nome_linea": "string",
"url_image": "string"
}
Indexes
- brand is a reference to
Brandcollection; - listaRefsOcchiale is a
[]of references toOcchialecollection.
Query examples
// Fetch the Reference Doc from Firebase
const lineaRefDoc = doc(db, "Linea", lineaId);
// Get the Document Snapshot from the Reference Doc
const lineaRefSnap = await getDoc(lineaRefDoc);
// Query lines by brand reference
const linesByBrand = query(
collection(db, "Linea"),
where("brand", "==", doc(db, "Brand", brandId))
);
// Query lines by associated glasses
const linesByGlasses = query(
collection(db, "Linea"),
where("listaRefsOcchiale", "array-contains", doc(db, "Occhiale", occhialeId))
);