Copying data from one env to the other


I have the following business case :

  • When I have a new customer I create a staging environment connecting to a staging database. People can iterate on custom settings
  • When they are ready I want to import all datas they have produce on the staging database to the prod database

Staging and prod apps are the same with same Meteor Collections.

Simple example I have a Customer collection when I have a new customer I create a document on this collection I want to copy the document from the Customer Collection of my staging database to the Customer collection of my prod database.

I thought I could use RemoteCollectionDriver like this :

const RemoteCollection = function (name, connectionString, connectionOptions) {
  return new Mongo.Collection(name, {
    _driver: new MongoInternals.RemoteCollectionDriver(connectionString, connectionOptions),

and then

const CustomersStaging = RemoteCollection("Customers", "mongo_url_of_staging")

But I have an error Error: There is already a collection named "Customers"

Do you know how can I do that ?


I found a way

const RemoteCollection = function (name, connectionString, connectionOptions) {
  const _driver = new MongoInternals.RemoteCollectionDriver(connectionString, connectionOptions);
1 Like

I don’t know your particular constraints, but it seems that, if possible, it would be much easier to just flag the document as in progress/unpublished rather than trying to work with 2 separate databases.