Skip to main content
Version: 1.0.0

LogVariant

Purpose​

The LogVariant collection records the workflow history and status changes for product variants. Each document logs key events such as creation, assignment, validation, and decline actions, along with timestamps, user accounts, and roles involved. This collection provides a complete audit trail for the lifecycle of each variant, supporting traceability, accountability, and process management.

Document schema​

{
"list_decline_variant": [
{
"account": "string",
"role": "string",
"time": "timestamp"
}
],
"list_init_variant": [
{
"account": "string",
"time": "timestamp"
}
],
"list_validate_variant": [
{
"account": "string",
"modeling_note": "string",
"role": "string",
"time": "timestamp",
"type_of_modeling": "string"
}
],
"list_variant_assigned": [
{
"account": "string",
"assignedAccount": "string",
"time": "timestamp"
}
],
"logCompleteVariantDate": "timestamp",
"logCreationDate": "timestamp",
"logInitVariantDate": "timestamp",
"logStatus": "string",
"productName": "string",
"sku": "string",
"variantId": "string"
}

Indexes​

  • variantId is a string that refers to the ID of the Variants collection.

Query examples​

// Fetch the LogVariant Reference Doc from Firebase
const logRef = doc(db, "LogVariant", logId);

// Get the Document Snapshot from the LogVariant Reference Doc
const logDoc = await getDoc(logRef);

// Creation of a new LogVariant Document
// After fetching the Variant Document from Firebase and its productName
const logData = {
list_decline_variant: [],
list_init_variant: [],
list_validate_variant: [],
list_variant_assigned: [],
logStatus: "Pending", // It becomes "Complete" when is "In Pubblicazione"
variantId: variantId,
productName: productName,
sku: variantData.skuModel || "",
};

// Create the Document and updates the references
const logRef = await addDoc(collection(db, "LogVariant"), logData);

await updateDoc(variantRef, {
refLogVariant: logRef.id,
});

await updateDoc(doc(db, "LogVariant", logRef.id), {
logCreationDate: Timestamp.now(),
});