fetchDatabase = async (remote) => {
  const { query } = remote;
  log.debug(`Fetching database ${query ? `with query '${query}' ` : ''}from remote ${remote.url}...`)
  const t0 = Date.now()
  return fetch(`${remote.url}/api/database.json${query ? `?q=${query}` : ''}`, options(remote))
    .then(res => {
      if (res.status == 404) {
        log.debug(t0, `Remote ${remote.url} has no database. Continue with empty database`)
        return { type: EventHeaderType, data: [] }
      } else if (!res.ok) {
        throw new Error(`Unexpected response status ${res.status}`)
      }
      return res.json()
    })
    .then(migrate)
    .then(database => {
      log.info(t0, `Fetched database with ${database?.data?.length || 0} entries from remote ${remote.url}`)
      return database
    })
}
@param {import('./types.js').Remote} remote
@returns {Promise<RemoteDatabase>}