@1amageek/document-propagator v0.12.1
document-propagator.ts
Cloud Firestore does not have Join Query. However, there are many use cases that require data joins. This library is designed to resolve CloudFirestore's Document dependencies.
Usage
The following code shows the Shop, Product, and Catalog dependencies of an EC.
Catalog depends on Product and Shop. Product depends on SKU.
export const dependency = propagator.resolve(getFirestore(app),
{ regions: ["asia-northeast1"] },
[
{
from: "/EC/{version}/shopDrafts/{shopID}",
to: "/EC/{version}/shops/{shopID}",
resources: [],
},
{
from: "/EC/{version}/shops/{shopID}/productDrafts/{productID}",
to: "/EC/{version}/shops/{shopID}/products/{productID}",
resources: [
{ documentID: "SKUIDs", field: "skus", resource: "/EC/{version}/shops/{shopID}/products/{productID}/SKUs/{skuID}" },
],
},
{
from: "/EC/{version}/shops/{shopID}/products/{productID}/SKUDrafts/{skuID}",
to: "/EC/{version}/shops/{shopID}/products/{productID}/SKUs/{skuID}",
resources: [],
},
{
from: "/EC/{version}/shops/{shopID}/catalogDrafts/{catalogID}",
to: "/EC/{version}/shops/{shopID}/catalog/{catalogID}",
resources: [
{ documentID: "shopID", field: "shop", resource: "/EC/{version}/shops" },
{ documentID: "productIDs", field: "products", resource: "/EC/{version}/shop/{shopID}/products" },
],
},
]
)
When the Draft is updated, Cloud Functions is triggered to retrieve the dependent data and merge the data. After the merged data is updated, the update is propagated to the data with dependencies.
8 months ago
8 months ago
12 months ago
1 year ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago