 #   * This is where to map object properties to columns and their headers
 #   * This is where you define custom templates for rendering data in cells
 
+# ##### setColumns()
 Template.dataTable.setColumns = ( columns ) ->
   Match.test columns, Array
   @setData 'columns', columns


# ## Querying MongoDB

# ### mapTableState()
#   * Take the `aoData` parameter of `fnServerData` and map it into a more usable object
#   * Convert aoData to key -> value pairs

Template.dataTable.mapTableState = ( aoData ) ->
  aoData = @arrayToDictionary aoData, 'name'
  @log 'mapTableState:aoData', aoData

  # #### tableState
  #   * `aoData.sEcho` is a request counter, incremented on every server call
  #   * `aoData.columns` contains the property meta data for each column
  #   * `aoData.iColumns` is the number of columns being displayed

# ##### setSubscriptionAutorun()
#   * creates a reactive computation that runs when the subscription is `ready()`
#   * sets up local cursor ( identical to server except no skip )
Template.dataTable.setSubscriptionAutorun = ( fnCallback ) ->
  Match.test fnCallback, Object
  if @getSubscriptionAutorun()
