CsvCollectionSourceModelAdapter constructor

const CsvCollectionSourceModelAdapter({
  1. List<ModelInitialValue>? initialValue,
  2. NoSqlDatabase? database,
  3. String? collectionPath,
  4. required String source,
  5. required String idKey,
  6. Map<String, String>? requestHeaders,
  7. String? requestMethod,
  8. String skipIdPrefix = "#",
})

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

The first line is treated as a header and the strings listed there as keys.

The elements of a row are the documents, and each row forms a collection.

1行目をヘッダーとして扱い、そこに記載されている文字列をキーとして扱います。

行の要素がドキュメントとなり、行ごとにコレクションが形成されます。

id,name,age
1,John,20
2,Tom,30
3,Alice,40

->

{
  "1": {
    "id": 1,
    "name": "John",
    "age": 20
  },
  "2": {
    "id": 2,
    "name": "Tom",
    "age": 30
  },
  "3": {
    "id": 3,
    "name": "Alice",
    "age": 40
  }
}

Implementation

const CsvCollectionSourceModelAdapter({
  super.initialValue,
  super.database,
  super.collectionPath,
  required super.source,
  required this.idKey,
  super.requestHeaders,
  super.requestMethod,
  this.skipIdPrefix = "#",
});