Skip to content

Commit

Permalink
Fix ignoring undefined firebase docs when importing from rowy (#114)
Browse files Browse the repository at this point in the history
The code intended to do so, but improperly, it looks like it's the first
time we ran into it. The reason is that when document has a
subcollection, deletion in Rowy doesn't trigger deletion of
subcollection recursively.

It would be cool to figure out how to cleanup that garbage in database,
but that's IMHO it's very low priority at the moment.
  • Loading branch information
p2004a authored Sep 2, 2023
1 parent 7da261b commit 7040765
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/js/src/update_from_rowy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ async function fetchDocuments(collection: FirebaseFirestore.CollectionReference<
const subFetches = [];
for (const doc of docs) {
const entry = doc.data();
if (entry) {
data[doc.id] = Object.fromEntries(entryKeys.filter(key => key in entry).map(key => [key, entry[key]]));
if (!entry) {
continue;
}
data[doc.id] = Object.fromEntries(entryKeys.filter(key => key in entry).map(key => [key, entry[key]]));
for (const [key, prop] of Object.entries(schema.additionalProperties.properties)) {
if (isTableSchema(prop)) {
subFetches.push(fetchConcurrentlyLimit(async () => {
Expand Down

0 comments on commit 7040765

Please sign in to comment.