JsonCollectionSourceModelAdapter class

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

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

URL, asset path, or Json 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.

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

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

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

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

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

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

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

Treat Json in the form of a Map of Map or a List of Map as a collection.

MapのMap、もしくはMapのListの形式のJsonをコレクションとして扱います。

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

->

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

Constructors

JsonCollectionSourceModelAdapter({List<ModelInitialValue>? initialValue, NoSqlDatabase? database, String? collectionPath, required String source, String? idKey, Map<String, String>? requestHeaders, String? requestMethod})
A database adapter that uses Json files as a data source.
const

Properties

availableListen bool
no setterinherited
collectionPath String?
The path of the destination as a collection.
finalinherited
database NoSqlDatabase
Designated database.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
idKey String?
Key of the map to be used as ID.
final
initialValue List<ModelInitialValue>?
Actual data when used as a mock-up.
finalinherited
requestHeaders Map<String, String>?
A request header sent when making a request as HTTP.
finalinherited
requestMethod String?
A request method sent when making a request as HTTP.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
source String
Data source.
finalinherited
validator DatabaseValidator?
Specify the permission validator for the database.
finalinherited

Methods

clearAll() Future<void>
Delete all data in the database.
inherited
deleteDocument(ModelAdapterDocumentQuery query) Future<void>
Delete data from the platform set by the adapter by passing query.
inherited
deleteOnBatch(ModelBatchRef ref, ModelAdapterDocumentQuery query) → void
Describe the data deletion process when performing a batch.
inherited
deleteOnTransaction(ModelTransactionRef ref, ModelAdapterDocumentQuery query) → void
Describe the data deletion process when performing a transaction.
inherited
disposeCollection(ModelAdapterCollectionQuery query) → void
The associated collection is discarded by passing query.
inherited
disposeDocument(ModelAdapterDocumentQuery query) → void
The destruction of related documents is handled by passing query.
inherited
fromJson(dynamic json) Map<String, DynamicMap>
Json data List can be retrieved in NoSqlDatabase Map.
override
listenCollection(ModelAdapterCollectionQuery query) Future<List<StreamSubscription>>
Pass query to monitor the collection.
inherited
listenDocument(ModelAdapterDocumentQuery query) Future<List<StreamSubscription>>
Pass query to monitor the document.
inherited
loadAggregation<T>(ModelAdapterCollectionQuery query, ModelAggregateQuery<AsyncAggregateValue> aggregateQuery) Future<T?>
Aggregate queries against data collections to retrieve data.
inherited
loadCollection(ModelAdapterCollectionQuery query) Future<Map<String, DynamicMap>>
Pass query to the platform set by the adapter to retrieve the collection.
inherited
loadDocument(ModelAdapterDocumentQuery query) Future<DynamicMap>
Pass query to the platform set by the adapter to retrieve the document.
inherited
loadOnTransaction(ModelTransactionRef ref, ModelAdapterDocumentQuery query) FutureOr<DynamicMap>
Describe the data acquisition process when performing a transaction.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
runBatch(FutureOr<void> batch(ModelBatchRef ref), int splitLength) FutureOr<void>
Processes a batch for execution.
inherited
runTransaction(FutureOr<void> transaction(ModelTransactionRef ref)) FutureOr<void>
Do the processing to execute the transaction.
inherited
saveDocument(ModelAdapterDocumentQuery query, DynamicMap value) Future<void>
By passing the query and the value to be stored, the data is stored on the platform set by the adapter.
inherited
saveOnBatch(ModelBatchRef ref, ModelAdapterDocumentQuery query, DynamicMap value) → void
Describe the data storage process when performing a batch.
inherited
saveOnTransaction(ModelTransactionRef ref, ModelAdapterDocumentQuery query, DynamicMap value) → void
Describes the data storage process when performing a transaction.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited