getById method

Future getById({
  1. bool autoAuthorize = true,
  2. String tag = '',
  3. List<String>? loadReference,
  4. String function = '',
  5. String method = 'GET',
  6. bool addCount = true,
  7. dynamic postData,
  8. bool autoRepeate = false,
  9. int autoRepeateCount = 1000,
  10. FutureOr<bool> retryIf(
    1. Exception
    )?,
  11. FutureOr<void> onRetry(
    1. Exception
    )?,
  12. NsgCancelToken? cancelToken,
})

Прочитать объект из БД по его идентификатору Можно использовать для обновления объекта из БД или для его дочитывания

Implementation

Future getById({
  bool autoAuthorize = true,
  String tag = '',
  List<String>? loadReference,
  String function = '',
  String method = 'GET',
  bool addCount = true,
  dynamic postData,
  bool autoRepeate = false,
  int autoRepeateCount = 1000,
  FutureOr<bool> Function(Exception)? retryIf,
  FutureOr<void> Function(Exception)? onRetry,
  NsgCancelToken? cancelToken,
}) async {
  var filter = NsgDataRequestParams();
  filter.compare.add(name: primaryKeyField, value: id, comparisonOperator: NsgComparisonOperator.equal);
  late NsgDataItem newItem;
  if (storageType == NsgDataStorageType.server) {
    var p = NsgDataRequest(dataItemType: runtimeType);
    newItem = await p.requestItem(
      filter: filter,
      autoAuthorize: autoAuthorize,
      tag: tag,
      loadReference: loadReference,
      function: function,
      method: method,
      addCount: addCount,
      postData: postData,
      autoRepeate: autoRepeate,
      autoRepeateCount: autoRepeateCount,
      retryIf: retryIf,
      onRetry: onRetry,
      cancelToken: cancelToken,
    );
  } else {
    newItem = (await NsgLocalDb.instance.requestItems(this, filter)).first;
  }
  copyFieldValues(newItem);
  state = newItem.state;
  docState = newItem.docState;
  // newTableLogic = newItem.newTableLogic;
}