Add a "schema migration" feature that add the ability to apply a transformation function before either writing to disk (so user can verify the schema migration) or before restoring to Firestore.
The proposal idea is to have a flag for this, called --transformFn or -T for the command line, where the user can indicate the path of a file from where the transformation function will be exported.
This transformation function should return a promise, and receive a object as parameter, which will contain the following fields:
accountDb {Object} Firestore database instance from where the backup is made
restoreAccountDb {Object} Firestore database instance where the backup is restored
collectionPath {Array} Array that contains the path of the collection
docId {String} Id of the document, where the function will be applied
docData {Object} Document data with "backup" format, specified below*
docData will have the format NAME: { "value": VALUE, "type": TYPE },
For example:
Add a "schema migration" feature that add the ability to apply a transformation function before either writing to disk (so user can verify the schema migration) or before restoring to Firestore.
The proposal idea is to have a flag for this, called
--transformFn
or-T
for the command line, where the user can indicate the path of a file from where the transformation function will be exported.And for example will be executed like this:
This transformation function should return a promise, and receive a object as parameter, which will contain the following fields:
accountDb
{Object} Firestore database instance from where the backup is maderestoreAccountDb
{Object} Firestore database instance where the backup is restoredcollectionPath
{Array} Array that contains the path of the collectiondocId
{String} Id of the document, where the function will be applieddocData
{Object} Document data with "backup" format, specified below*docData
will have the formatNAME: { "value": VALUE, "type": TYPE },
For example:The allowed types are: 'string', 'number', 'boolean', 'object', 'array', 'null', 'timestamp', 'geopoint', 'documentReference'
Example of transformation function:
MyCompany
, tocompany
in all the documents ofCompanies
export default transformFn;