createIndex() public method
Creates an index on the collection and the specified fields.
public boolean createIndex ( $columns, $options = [] )$columns
array|string
Column name or list of column names. If array is given, each element in the array has as key the field name, and as value either 1 for ascending sort, or -1 for descending sort. You can specify field using native numeric key with the field name as a value, in this case ascending sort will be used. For example: [
'name',