How to copy a document with a couple changes?

How to create a document using an existing document from the same collection as a template?

The template document would have a special, known identifier, and the new document would differ in identifier.

Hello @Collin,

You will need to Get the “template” before creating your new document.

Let({
  template: Select('data', Get(Ref(Collection('col'), 'templateId')))
},
  Create(
    Collection('col'),
    {
       data: Merge(
               Var('template'),
               body // data to update
             )
    }
  )
)

You could create it as an UDF if needed !

3 Likes