Created
December 24, 2023 11:46
-
-
Save nevehallon/81b74bc045ab6dfcdc8497ae3c5f046c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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