jsonArrInsert method

Future<int> jsonArrInsert(
  1. String key,
  2. Object value, {
  3. String path = '\$',
  4. int? start,
  5. int? end,
})

jsonArrInsert

Implementation

Future<int> jsonArrInsert(
  String key,
  Object value, {
  String path = '\$',
  int? start,
  int? end,
}) async {
  List<RespType<dynamic>>? result = await _runWithRetryNew(() async {
    return (await RespCommandsTier1(_client!).jsonArrIndex(
      key: key,
      path: path,
      value: value,
      start: start,
      end: end,
    ))
        .toArray()
        .payload;
  });

  if (result != null && result.isNotEmpty) {
    return result[0].payload as int; // 确保 payload 是 int 类型
  } else {
    throw Exception('jsonArrAppend: No elements in the result list');
  }
}