0.12.1 • Published 8 months ago

@1amageek/document-propagator v0.12.1

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

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.

スクリーンショット 2022-12-13 22 02 10

Catalog depends on Product and Shop. Product depends on SKU.

スクリーンショット 2022-12-13 22 02 15

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.

0.12.0

8 months ago

0.12.1

8 months ago

1.0.0

12 months ago

0.10.9

1 year ago

0.11.0

12 months ago

0.10.1

1 year ago

0.10.2

1 year ago

0.10.3

1 year ago

0.10.10

1 year ago

0.10.5

1 year ago

0.10.11

1 year ago

0.10.6

1 year ago

0.10.7

1 year ago

0.10.8

1 year ago

0.10.0

1 year ago

0.9.0

1 year ago

0.8.0

1 year ago

0.9.1

1 year ago

0.7.0

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.4.3

1 year ago

0.5.1

1 year ago

0.4.2

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago