appendLabel method

Future<String> appendLabel(
  1. String targetId,
  2. String? label
)

Attaches (or removes, when label is null) a label to targetId. Returns the new record id.

Implementation

Future<String> appendLabel(String targetId, String? label) async {
  if (await _storage.getEntry(targetId) == null) {
    throw SessionException(
      'Entry $targetId not found',
      code: SessionErrorCode.notFound,
    );
  }
  return _append(
    (id, parentId) => LabelRecord(
      id: id,
      parentId: parentId,
      timestamp: DateTime.now(),
      targetId: targetId,
      label: label,
    ),
  );
}