updateSpecifications method

Future<Map<String, dynamic>> updateSpecifications(
  1. String index,
  2. String collection,
  3. Map<String, dynamic> specifications
)

You can specify validation specifications in order to enforce your own rules over documents and real-time messages. Whenever a document is stored or updated, or a message is published, Kuzzle applies these specifications to check if the new data complies to the defined rules. If not, the document or message will be rejected and the request will return an error message.

The updateSpecifications method allows you to create or update the validation specifications for one or more index/collection pairs.

When the validation specification is not formatted correctly, a detailed error message is returned to help you to debug.

Implementation

Future<Map<String, dynamic>> updateSpecifications(
  String index,
  String collection,
  Map<String, dynamic> specifications,
) async {
  final response = await kuzzle.query(KuzzleRequest(
    controller: name,
    index: index,
    collection: collection,
    action: 'updateSpecifications',
    body: specifications,
  ));

  final result = response.result as Map<String, dynamic>;

  if (result['fields'] is Map) {
    return result;
  }

  throw BadResponseFormatError(
    response.error?.id,
    'UpdateSpecifications: bad response format',
    response,
  );
}