insert method

List<Status> insert(
  1. List<Doc> docs
)

Implementation

List<Status> insert(List<Doc> docs) {
  _ensureOpen();
  final results = <Status>[];

  for (final doc in docs) {
    try {
      final vector = doc.vectors[schema.primaryVector.name];
      if (vector == null) {
        throw ZvecException(
          -1,
          'Doc ${doc.id} is missing vector field ${schema.primaryVector.name}.',
        );
      }

      final mapped = _mapFieldsForNative(doc.fields);
      _raw.insert(
        id: doc.id,
        vector: vector,
        content: mapped.content,
        metadata: mapped.metadata,
        hash: mapped.hash,
      );
      results.add(const Status.ok());
    } catch (error) {
      results.add(_statusFromError(error));
    }
  }

  return results;
}