Readonly
traverserThe underlying traverser.
Deletes the specified field from all documents in this collection.
The field to delete.
A Promise resolving to an object representing the details of the migration.
Complexity:
traverser
) where C(batchSize
) = W(batchSize
)traverser
) where S = O(batchSize
)where:
batchSize
): average batch write timetraverser
): time complexity of the underlying traversertraverser
): space complexity of the underlying traverserDeletes the specified fields from all documents in this collection.
Rest
...fields: (string | FieldPath)[]A list of fields to delete.
A Promise resolving to an object representing the details of the migration.
Complexity:
traverser
) where C(batchSize
) = W(batchSize
)traverser
) where S = O(batchSize
)where:
batchSize
): average batch write timetraverser
): time complexity of the underlying traversertraverser
): space complexity of the underlying traverserconst field1 = new firestore.FieldPath('name', 'last');
const field2 = 'lastModifiedAt';
await migrator.deleteFields(field1, field2);
Registers a callback function that fires after a batch is processed. You can register at most 1 callback. If you call this function multiple times, only the last callback will be registered.
A synchronous callback that takes batch doc snapshots and the 0-based batch index as its arguments.
Registers a callback function that fires right before a batch starts processing. You can register at most 1 callback. If you call this function multiple times, only the last callback will be registered.
A synchronous callback that takes batch doc snapshots and the 0-based batch index as its arguments.
Renames the specified field in all documents in this collection. Ignores the fields that are missing.
The old field.
The new field.
A Promise resolving to an object representing the details of the migration.
Complexity:
traverser
) where C(batchSize
) = W(batchSize
)traverser
) where S = O(batchSize
)where:
batchSize
): average batch write timetraverser
): time complexity of the underlying traversertraverser
): space complexity of the underlying traverserRenames the specified fields in all documents in this collection. Ignores the fields that are missing.
Rest
...changes: [oldField: string | FieldPath, newField: string | FieldPath][]A list of [oldField, newField]
tuples. Each tuple is an array of 2 elements:
the old field to rename and the new field.
A Promise resolving to an object representing the details of the migration.
Complexity:
traverser
) where C(batchSize
) = W(batchSize
)traverser
) where S = O(batchSize
)where:
batchSize
): average batch write timetraverser
): time complexity of the underlying traversertraverser
): space complexity of the underlying traverserconst change1 = [new firestore.FieldPath('name', 'last'), 'lastName'];
const change2 = ['lastModifiedAt', 'lastUpdatedAt'];
await migrator.renameFields(change1, change2);
Sets all documents in this collection with the provided data.
A data object with which to set each document.
An object to configure the set behavior.
A Promise resolving to an object representing the details of the migration.
Complexity:
traverser
) where C(batchSize
) = W(batchSize
)traverser
) where S = O(batchSize
)where:
batchSize
): average batch write timetraverser
): time complexity of the underlying traversertraverser
): space complexity of the underlying traverserSets all documents in this collection with the provided data.
A data object with which to set each document.
A Promise resolving to an object representing the details of the migration.
Complexity:
traverser
) where C(batchSize
) = W(batchSize
)traverser
) where S = O(batchSize
)where:
batchSize
): average batch write timetraverser
): time complexity of the underlying traversertraverser
): space complexity of the underlying traverserSets all documents in this collection with the provided data.
A function that takes a document snapshot and returns a data object with which to set each document.
An object to configure the set behavior.
A Promise resolving to an object representing the details of the migration.
Complexity:
traverser
) where C(batchSize
) = W(batchSize
)traverser
) where S = O(batchSize
)where:
batchSize
): average batch write timetraverser
): time complexity of the underlying traversertraverser
): space complexity of the underlying traverserSets all documents in this collection with the provided data.
A function that takes a document snapshot and returns a data object with which to set each document.
A Promise resolving to an object representing the details of the migration.
Complexity:
traverser
) where C(batchSize
) = W(batchSize
)traverser
) where S = O(batchSize
)where:
batchSize
): average batch write timetraverser
): time complexity of the underlying traversertraverser
): space complexity of the underlying traverserUpdates all documents in this collection with the provided data.
A non-empty data object with which to update each document.
Optional
precondition: PreconditionA Precondition to enforce on this update.
A Promise resolving to an object representing the details of the migration.
Complexity:
traverser
) where C(batchSize
) = W(batchSize
)traverser
) where S = O(batchSize
)where:
batchSize
): average batch write timetraverser
): time complexity of the underlying traversertraverser
): space complexity of the underlying traverserUpdates all documents in this collection with the provided field-value pair.
The first field to update in each document.
The first value corresponding to the first field. Must not be undefined
.
Rest
...moreFieldsOrPrecondition: any[]An alternating list of field paths and values to update, optionally followed by a Precondition to enforce on this update.
A Promise resolving to an object representing the details of the migration.
Complexity:
traverser
) where C(batchSize
) = W(batchSize
)traverser
) where S = O(batchSize
)where:
batchSize
): average batch write timetraverser
): time complexity of the underlying traversertraverser
): space complexity of the underlying traverserUpdates all documents in this collection with the provided data.
A function that takes a document snapshot and returns a non-empty data object with which to update each document.
Optional
precondition: PreconditionA Promise resolving to an object representing the details of the migration.
Complexity:
traverser
) where C(batchSize
) = W(batchSize
)traverser
) where S = O(batchSize
)where:
batchSize
): average batch write timetraverser
): time complexity of the underlying traversertraverser
): space complexity of the underlying traverserUpdates all documents in this collection with the provided data.
A function that takes a document snapshot and returns an alternating list of field paths and values to update, optionally followed by a Precondition to enforce on this update.
A Promise resolving to an object representing the details of the migration.
Complexity:
traverser
) where C(batchSize
) = W(batchSize
)traverser
) where S = O(batchSize
)where:
batchSize
): average batch write timetraverser
): time complexity of the underlying traversertraverser
): space complexity of the underlying traverserApplies a migration predicate that indicates whether to migrate the current document or not. By default, all documents are migrated.
A function that takes a document snapshot and returns a boolean indicating whether to migrate it.
A new DefaultMigrator object.
If you have already applied other migration predicates to this migrator, this and all the other predicates will be evaluated and the resulting booleans will be AND'd to get the boolean that indicates whether to migrate the document or not. This is consistent with the intuitive default behavior that all documents are migrated.
const newMigrator = migrator
.withPredicate((doc) => doc.get('name') !== undefined)
.withPredicate((doc) => doc.ref.path.startsWith('users/'));
In the above case newMigrator
will migrate only the documents whose name
field is not missing AND whose path
starts with "users/"
.
Applies a new traverser that will be used by the migrator.
The new traverser that the migrator will use.
A new DefaultMigrator object.
Generated using TypeDoc
A batch migrator object that does not use atomic batch writes.