code: func (db *DB) NewIndex(name string, funcs IndexFuncs) (f Index, err error) {
  	id, err := db.schemaIndexPrefix(name)
  	if err != nil {
  		return f, err
  	}
  	prefix := []byte{id}
  	return Index{
  		db:     db,
  		prefix: prefix,
  		// This function adjusts Index LevelDB key
  		// by appending the provided index id byte.
  		// This is needed to avoid collisions between keys of different
  		// indexes as all index ids are unique.
  		encodeKeyFunc: func(e Item) (key []byte, err error) {
  			key, err = funcs.EncodeKey(e)
  			if err != nil {
  				return nil, err
  			}
  			return append(append(make([]byte, 0, len(key)+1), prefix...), key...), nil
  		},
  		// This function reverses the encodeKeyFunc constructed key
  		// to transparently work with index keys without their index ids.
  		// It assumes that index keys are prefixed with only one byte.
  		decodeKeyFunc: func(key []byte) (e Item, err error) {
  			return funcs.DecodeKey(key[1:])
  		},
  		encodeValueFunc: funcs.EncodeValue,
  		decodeValueFunc: funcs.DecodeValue,
  	}, nil
  }
docs: // NewIndex returns a new Index instance with defined name and
  // encoding functions. The name must be unique and will be validated
  // on database schema for a key prefix byte.