async function initializeDatabase(database) {
  // Adds a index to quickly search by path
  await database.createIndex({
    index: {
      fields: ['pathElements']
    }
  })
    .catch(err => {
      throw unknowError(err)
    })

  // Constructs a view to manage the hiearchy
  const pathViewDocument = {
    _id: '_design/path',
    views: {
      path: {
        map: function (doc) {
          /* eslint no-undef: "off" */
          emit(doc.pathElements, doc)
        }.toString()
      }
    }
  }
  await database.put(pathViewDocument)
    .catch(err => {
      if (err.name !== 'conflict') {
        throw err
      }
    })
    .catch(err => {
      throw unknowError(err)
    })

  await writeInitializedFlagDocument(database)
}
/**
 * Intializes a PouchDb database to be a valid FileStorage
 * @private
 */
Intializes a PouchDb database to be a valid FileStorage
@private
Intializes a PouchDb database to be a valid FileStorage @private
async function initializeDatabase(database) {
  await database.createIndex({
    index: {
      fields: ['pathElements']
    }
  })
    .catch(err => {
      throw unknowError(err)
    })
  const pathViewDocument = {
    _id: '_design/path',
    views: {
      path: {
        map: function (doc) {
          emit(doc.pathElements, doc)
        }.toString()
      }
    }
  }
  await database.put(pathViewDocument)
    .catch(err => {
      if (err.name !== 'conflict') {
        throw err
      }
    })
    .catch(err => {
      throw unknowError(err)
    })
  await writeInitializedFlagDocument(database)
}
async function initializeDatabase ( database ) { await database . createIndex ( { index : { fields : [ 'pathElements' ] } } ) . catch ( err => { throw unknowError ( err ) } ) const pathViewDocument = { _id : '_design/path' , views : { path : { map : function ( doc ) { emit ( doc . pathElements , doc ) } . toString ( ) } } } await database . put ( pathViewDocument ) . catch ( err => { if ( err . name !== 'conflict' ) { throw err } } ) . catch ( err => { throw unknowError ( err ) } ) await writeInitializedFlagDocument ( database ) }
Intializes a PouchDb database to be a valid FileStorage
 @private
Intializes a PouchDb database to be a valid FileStorage @private
// Adds a index to quickly search by path // Constructs a view to manage the hiearchy /* eslint no-undef: "off" */