Skip to content

Instantly share code, notes, and snippets.

@nevehallon
Created December 24, 2023 11:46
Show Gist options
  • Save nevehallon/81b74bc045ab6dfcdc8497ae3c5f046c to your computer and use it in GitHub Desktop.
Save nevehallon/81b74bc045ab6dfcdc8497ae3c5f046c to your computer and use it in GitHub Desktop.
const Bagel = require('@bageldb/bagel-db')
const dev = new Bagel(process.env.DEV_TOKEN) // needs write access
const prod = new Bagel(process.env.PROD_TOKEN) // must have read access
// mark the collections you want to copy (ensure the tokens have the right permissions)
const collections =[
// "clients", "testimonials", ...
]
const cloneProd = async () => {
for (const collection of collections) {
const {data} = await prod.collection(collection).everything().get()
await Promise.all(data.map(async (item) => dev.collection(collection).item(item._id).set(item)))
}
}
cloneProd()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment