Index
public struct Index: Indexer
                Indexer implemenation to define a Database index used to query the database
Example:
   let index = Database.Index(name: "myView", version: "1.0", map: { (document, addRow) in
       if let type = document["type"] {
           addRow(type, nil)
       }
   })
   let config = Database.OpenDatabaseConfiguration(indexes: [index])
          - 
                  
                  
Declaration
Swift
public private(set) var name: String - 
                  
                  
Declaration
Swift
public private(set) var version: String - 
                  
                  
Declaration
Swift
public private(set) var map: Indexer.Map - 
                  
                  
Declaration
Swift
public private(set) var reduce: Indexer.Reduce? - 
                  
                  
Initialization of new Index
Important
Versioning:Once created, a database index is stored as part of the data in database, for this reason, changes to an index require special handling.
If any part of the
mapfunction orreducefunction change, theversionstring should be changed to ensure the index is properly updated. Failure to change this value when updating the code will lead to unpredicable results.Example:
let index = Database.Index(name: "myView", version: "1.0", map: { (document, addRow) in if let type = document["type"] { addRow(type, nil) } }) let config = Database.OpenDatabaseConfiguration(indexes: [index])Declaration
Swift
public init(name: String, version: String, map: @escaping Map, reduce: Reduce? = nil)Parameters
nameName of the index, required to run queries against the index.
versionVersion of the index. See Versioning above
mapMapclosure that defines the index. For further information see themapproperty.reduceOptional
Reduceclosure that performs summarization during queries. For further information see thereduceproperty. 
            View on GitHub
          
      Index Structure Reference