insertMany method

Future<void> insertMany(
  1. List<Map<String, dynamic>> documents
)

Implementation

Future<void> insertMany(List<Map<String, dynamic>> documents) async {
  for (final document in documents) {
    final id = document["id"] ?? document["_id"] ?? HarnUtils.generateId();
    final createdAt = document["createdAt"] ?? HarnUtils.generateTimeStamp();
    final updatedAt = document["updatedAt"] ?? HarnUtils.generateTimeStamp();
    Task task = Task("insert", () async {
      collection[id] = {
        ...convertDateTimeToString(document),
        '_id': id,
        'createdAt': createdAt.toIso8601String(),
        'updatedAt': updatedAt.toIso8601String(),
      };
    });
    harnCollectionQueue.enqueue(task);
    _notifyDocumentCreated(id);
  }
  // await _saveCollection();
}