Cloud Functions: How to copy Firestore Collection to a new document?

I’d like to make a copy of a collection in Firestore upon an event using Cloud Functions

I already have this code that iterates over the collection and copies each document

const firestore = admin.firestore()
firestore.collection("products").get().then(query => {
  query.forEach(function(doc) {
    var promise = firestore.collection(uid).doc(;

is there a shorter version? to just copy the whole collection at once?

136 thoughts on “Cloud Functions: How to copy Firestore Collection to a new document?”

  1. I blog frequently and I seriously appreciate your content.
    Your article has really peaked my interest. I’m going to take a note of
    your blog and keep checking for new information about
    once per week. I subscribed to your RSS feed too.

  2. Hey there are using WordPress for your site platform?
    I’m new to the blog world but I’m trying to get started and set up
    my own. Do you require any html coding expertise to make your
    own blog? Any help would be greatly appreciated!

  3. Please let me know if you’re looking for a writer for
    your blog. You have some really great posts and
    I believe I would be a good asset. If you ever want to take
    some of the load off, I’d really like to write some articles
    for your blog in exchange for a link back to mine.
    Please shoot me an e-mail if interested. Thanks!

  4. Undeniably imagine that which you stated. Your favourite reason appeared to be on the net the easiest factor to
    have in mind of. I say to you, I certainly get irked at the same time as folks think about
    issues that they plainly do not understand about. You controlled to hit the nail upon the highest and also defined out the whole thing with
    no need side-effects , people can take a signal. Will probably be back to get more.

  5. What you posted was very logical. However, what about this?
    suppose you added a little content? I am not saying your content is not
    good., but suppose you added something to maybe get a person’s attention? I mean Cloud
    Functions: How to copy Firestore Collection to a new document?
    – JavaScript Help is kinda plain. You should peek
    at Yahoo’s home page and see how they create post headlines to get viewers interested.
    You might add a video or a related picture or two to grab people interested about everything’ve
    written. In my opinion, it would make your posts a little livelier.
    scoliosis surgery scoliosis surgery

  6. Hey I know this is off topic but I was wondering if you knew
    of any widgets I could add to my blog that automatically tweet my newest twitter
    updates. I’ve been looking for a plug-in like this for quite some time and was hoping
    maybe you would have some experience with something like
    this. Please let me know if you run into anything.

    I truly enjoy reading your blog and I look forward to your new
    updates. quest bars quest bars

  7. Hi there, I discovered your blog by means
    of Google even as looking for a similar subject, your site came up,
    it appears to be like good. I have bookmarked it in my google
    Hi there, just became aware of your blog through Google, and located that it’s
    truly informative. I am gonna be careful for brussels.
    I will appreciate if you proceed this in future. Numerous
    people shall be benefited from your writing.
    Cheers! quest bars quest bars

  8. This design is steller! You definitely know how to keep a reader amused. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Great job. I really loved what you had to say, and more than that, how you presented it. Too cool!|


Leave a Comment