CsvDocumentSourceModelAdapter constructor

const CsvDocumentSourceModelAdapter({
  1. List<ModelInitialValue>? initialValue,
  2. NoSqlDatabase? database,
  3. String? collectionPath,
  4. String? documentId,
  5. required String source,
  6. Offset? offset,
  7. Axis direction = Axis.horizontal,
  8. Map<String, String>? requestHeaders,
  9. String? requestMethod,
})

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を指定するとデータベース内でのバリデーションが行われます。

Treats a CSV with a sequence of keys and values as a document. It cannot be used as a collection.

If direction is set to Axis.horizontal, data can be defined in the horizontal direction.

If direction is set to Axis.vertical, data can be defined in the vertical direction.

The offset of the data can be specified with offset.

キーと値が並んだCSVをドキュメントとして扱います。コレクションとしては利用できません。

directionAxis.horizontalにすると横方向にデータを定義できます。

directionAxis.verticalにすると縦方向にデータを定義できます。

offsetでデータのオフセットを指定できます。

// Horizontal
id,name,age
1,John,20

// Vertical
id,1
name,John
age,20

->

{
  "id": 1,
  "name": "John",
  "age": 20
}

Implementation

const CsvDocumentSourceModelAdapter({
  super.initialValue,
  super.database,
  super.collectionPath,
  this.documentId,
  required super.source,
  this.offset,
  this.direction = Axis.horizontal,
  super.requestHeaders,
  super.requestMethod,
});