Firestore data bundles

111 views
Skip to first unread message

South Croydon

unread,
Jul 8, 2023, 7:30:09 AMJul 8
to google-cloud-firestore-discuss
Hi,
and would love to use in my project.

I started following the documentation but stuck in configuration. As asked in the blog, I posted on stackoverflow


Can I get some help with a full working example involving client calls, function,  data bundle extension configuration endpoints, parameters ?

Regards

wua...@google.com

unread,
Jul 10, 2023, 1:57:09 PMJul 10
to google-cloud-firestore-discuss
Hi there,

I think there are couple things to understand about bundles:

1. It is meant for the Mobile/Web SDKs to consume the built bundles. They are meant to be stored somewhere (CDN, Cloud Storage, etc). In the stackoverflow post, it seems like you are trying to serve bundles from a Cloud Function instance? In this case, you should manually construct your bundles using the Admin SDKs, instead of using the extension (https://firebase.google.com/docs/extensions/official/firestore-bundle-builder).

2. That extension is a no-code solution for building and serving (caching via Firebase Hosting and Cloud Storage) bundles. What it does is to automatically create a Cloud Function instance, reading from a Firestore Document and using it as specifications of how bundles can be built.

If you are using that extension, in the specification Document, field `Documents` should be the document path that are supposed to be in the bundle, alternatively you can also specify a `Query` to use to build the bundle. `Params` are placeholders you put in your queries, they will need to be specified via http parameters when you request for the bundle.

Bundles are a complex feature, and requires some coordination between Server (or Extension), and Client SDKs. Please make sure you have a good understanding on how it works before you implement your feature. 

Thanks

South Croydon

unread,
Jul 10, 2023, 4:46:58 PMJul 10
to google-cloud-firestore-discuss
I sent a reply, but I can't see it here

South Croydon

unread,
Jul 11, 2023, 12:00:45 PMJul 11
to google-cloud-firestore-discuss
Thanks for your reply.

My Objective is to reduce the number of unnecessary reads and writes

About Point 1 - Yes. I already have a mechanism to get data. Next step is to make use of bundles.

"In this case, you should manually construct your bundles using the Admin SDKs,"  - How can I do this ? Any pointers please

(I  am ok even if I have to manually create it everyday and save in cloud storage.)

Thank you

South Croydon

unread,
Jul 11, 2023, 12:08:46 PMJul 11
to google-cloud-firestore-discuss
Thank you  Wuandy

The link given by you  is promising

But what should I do ? When will the function get triggered ? and the frequency.

const bundle = firestore.bundle('data-bundle'); const docSnapshot = await firestore.doc('abc/123').get(); const querySnapshot = await firestore.collection('coll').get(); const bundleBuffer = bundle.add(docSnapshot) // Add a document .add('coll-query', querySnapshot) // Add a named query. .build() // Save `bundleBuffer` to CDN or stream it to clients.

I have a lot of questions to understand the flow. 1. data-bundle - where will this get created. 2. How this function gets triggered? 3. How my code use this bundle rather than get() 

South Croydon

unread,
Sep 3, 2023, 12:05:27 PMSep 3
to google-cloud-firestore-discuss
Hi,
It would be nice if firebase team helps me.

Mr Duckworth?
Mr  Todd Kerpelman ?

when will  Build the bundle happen ?

var bundleId = "latest-stories";
var bundle = firestore.bundle(bundleId)

...
// Build the bundle
// Note how querySnapshot is named "latest-stories-query"



" Assume the bundle created in the previous section has been saved to a file named bundle.txt "
why I need to assume ?? If the documentation says step 1 creates "sample.txt", continue that in step 2 .

firebase team can you give a full fledged example??
Reply all
Reply to author
Forward
0 new messages