     console.log "Create files and database store"
     @fileStore = db.createObjectStore "files", {autoIncrement: true}
     @catalogStore = db.createObjectStore "catalog", {autoIncrement: true}
+
+    @catalogIndex = @catalogStore.createIndex "catalogByGrid", ['gridN', 'gridM', 'funcId', 'name', 'time'], {unique: false}
     
     @populated = false
 

    console.log "Loaddata"
    transaction = @db.transaction ["catalog"], "readonly"
    filesStore = transaction.objectStore "catalog"
    cursor = filesStore.openCursor()
    @loadFromCursor cursor, (rec)->true

  loadDataFor: (gridN, gridM, funcId) ->
    transaction = @db.transaction ["catalog"], "readonly"
    filesStore = transaction.objectStore "catalog"
    #create range

    filesEnumerated = 0
    
    onRecord = (res, record)=>
      #console.log "Found file: #{res.key}" if res?
      grid = "{#{record.gridN};#{record.gridM}}"
      if grid isnt lastGrid
        #loading next group
