replaceAllObjects method

Future<AlgoliaTask> replaceAllObjects(
  1. List<Map<String, dynamic>> objects
)

ReplaceAllObjects

Replace all the objerts in the index referred to by this AlgoliaIndexReference.

Implementation

Future<AlgoliaTask> replaceAllObjects(
    List<Map<String, dynamic>> objects) async {
  final tempIndex = algolia.index(Uuid().v4());
  final copyTask = await copyIndex(
    destination: tempIndex.index,
    scopes: [
      CopyScope.Settings,
      CopyScope.Synonyms,
      CopyScope.Rules,
    ],
  );
  await copyTask.waitTask();
  final batchTask = await tempIndex.addObjects(objects);
  await batchTask.waitTask();
  return await tempIndex.moveIndex(destination: index);
}