Index.fromMap constructor

Index.fromMap(
  1. Map<String, dynamic> map
)

Implementation

factory Index.fromMap(
  Map<String, dynamic> map,
) {
  map = {
    '\$id': "",
    '\$createdAt': "",
    '\$updatedAt': "",
    'key': "",
    'description': "",
    'type': "",
    'error': "",
    'attributes': [],
    'lengths': [],
    ...map,
  };

  return Index(
    $id: map['\$id'].toString(),
    $createdAt: map['\$createdAt'].toString(),
    $updatedAt: map['\$updatedAt'].toString(),
    key: map['key'].toString(),
    description: map['description'].toString(),
    type: map['type'].toString(),
    status: enums.IndexStatus.values.firstWhere(
      (e) => e.value == map['status'],
    ),
    error: map['error'].toString(),
    attributes: List.from(map['attributes'] ?? []),
    lengths: List.from(map['lengths'] ?? []),
    orders: List.from(map['orders'] ?? []),
  );
}