kevlened / fireway

A schema migration tool for firestore
MIT License
277 stars 41 forks source link

Configure Firestore Settings throws error #38

Open MNorgren opened 3 years ago

MNorgren commented 3 years ago

I want to configure my firestore settings for a specific migration. I need to set "ignoreUndefinedProperties: true". When I do this within the migrate function, I receive an error that Firestore has already been initialized. Is there a way to configure firestore settings?

export async function migrate({firestore} : MigrateOptions) {
  firestore.settings({ timestampsInSnapshots: true, ignoreUndefinedProperties: true });
  ...
}
MNorgren commented 3 years ago

If anyone else is needing to do something similiar, I was able to work around this config issue with the following HACK:

// HACK: Changing ignored undefined properties
const tempFireStore = firestore as any;
tempFireStore._settingsFrozen = false;
tempFireStore.settings({ignoreUndefinedProperties: true});
tempFireStore._settingsFrozen = true;
hellovai commented 2 years ago

Thanks! The workaround for me now as well :)