CsvSourceModelAdapter constructor

const CsvSourceModelAdapter({
  1. NoSqlDatabase? database,
  2. List<ModelInitialValue>? initialValue,
  3. required String source,
  4. Map<String, String>? requestHeaders,
  5. String? requestMethod,
  6. String? collectionPath,
  7. DatabaseValidator? validator,
})

A database adapter that uses CSV files as a data source.

CSV files can be used as configuration files for settings and other purposes.

URL, asset path, or CSV data can be directly specified in source.

requestHeaders specifies request headers to be sent when requesting as HTTP.

requestMethod specifies the request method to be sent when requesting as HTTP.

By passing data to initialValue, the database can be used as a data mockup because it contains data in advance.

If validator is specified, validation is performed in the database.

CSVファイルをデータソースとして利用するデータベースアダプター。

CSVファイルで設定などを行う場合、設定ファイルとして利用することができます。

sourceにはURLやアセットパス、CSVデータを直接指定することができます。

requestHeadersにはHTTPとしてリクエストする際に送るリクエストヘッダーを指定します。

requestMethodにはHTTPとしてリクエストする際に送るリクエストメソッドを指定します。

initialValueにデータを渡すことで予めデータが入った状態でデータベースを利用することができるためデータモックとして利用することができます。

validatorを指定するとデータベース内でのバリデーションが行われます。

CSV data is converted to Map by writing the process for conversion in fromCsv.

fromCsvに変換用の処理を記述することでCSVのデータをMapに変換します。

Implementation

const CsvSourceModelAdapter({
  NoSqlDatabase? database,
  this.initialValue,
  required this.source,
  this.requestHeaders,
  this.requestMethod,
  this.collectionPath,
  this.validator,
}) : _database = database;