refresh(entity) {
    if (!(entity instanceof AbstractEntity)) {
      throw new TypeError("The entity must an AbstractEntity instance")
    }
    let entityClass = entity.constructor
    validateEntityClass(entityClass)

    let storeName = entityClass.objectStore
    let keyPath
    let primaryKey
    if (this[PRIVATE.rwTransactionRunner]) {
      return this[PRIVATE.runTransactionOperation]((transaction) => {
        let objectStore = transaction.getObjectStore(storeName)
        keyPath = objectStore.keyPath
        primaryKey = getPrimaryKey(entity, keyPath)
        return objectStore.get(primaryKey)
      }).then(processRefreshedData.bind(this))
    }

    return this[PRIVATE.connection].then((database) => {
      return database.runReadOnlyTransaction(storeName, (objectStore) => {
        keyPath = objectStore.keyPath
        primaryKey = getPrimaryKey(entity, keyPath)
        return objectStore.get(primaryKey)
      })
    }).then(processRefreshedData.bind(this))

    function processRefreshedData(entityData) {
      if (!this[PRIVATE.entities].has(entityClass)) {
        this[PRIVATE.entities].set(entityClass, new Map())
      }

      let entities = this[PRIVATE.entities].get(entityClass)
      let serializedKey = serializeKey(primaryKey)
      entities.set(serializedKey, {
        data: clone(entityData),
        entity
      })

      Object.assign(entity, entityData)
      this[PRIVATE.deleteExtraneousFields](entity, entityData)
      return entity
    }
  }
/**
   * Reloads the state of the provided entity from the database. The entity
   * will be modified in place asynchronously.
   *
   * @template {T} extends AbstractEntity
   * @param {T} entity The entity that should have its state reloaded. The
   *        entity does not have to be currently managed by this entity
   *        manager.
   * @return {Promise<T>} A promise that resolves to the reloaded entity.
   */
Reloads the state of the provided entity from the database. The entity
will be modified in place asynchronously.

@template {T} extends AbstractEntity
@param {T} entity The entity that should have its state reloaded. The
entity does not have to be currently managed by this entity
manager.
@return {Promise} A promise that resolves to the reloaded entity.
Reloads the state of the provided entity from the database . The entity will be modified in place asynchronously . @template { T } extends AbstractEntity @param { T } entity The entity that should have its state reloaded . The entity does not have to be currently managed by this entity manager . @return { Promise } A promise that resolves to the reloaded entity .
refresh(entity) {
    if (!(entity instanceof AbstractEntity)) {
      throw new TypeError("The entity must an AbstractEntity instance")
    }
    let entityClass = entity.constructor
    validateEntityClass(entityClass)
    let storeName = entityClass.objectStore
    let keyPath
    let primaryKey
    if (this[PRIVATE.rwTransactionRunner]) {
      return this[PRIVATE.runTransactionOperation]((transaction) => {
        let objectStore = transaction.getObjectStore(storeName)
        keyPath = objectStore.keyPath
        primaryKey = getPrimaryKey(entity, keyPath)
        return objectStore.get(primaryKey)
      }).then(processRefreshedData.bind(this))
    }
    return this[PRIVATE.connection].then((database) => {
      return database.runReadOnlyTransaction(storeName, (objectStore) => {
        keyPath = objectStore.keyPath
        primaryKey = getPrimaryKey(entity, keyPath)
        return objectStore.get(primaryKey)
      })
    }).then(processRefreshedData.bind(this))
    function processRefreshedData(entityData) {
      if (!this[PRIVATE.entities].has(entityClass)) {
        this[PRIVATE.entities].set(entityClass, new Map())
      }
      let entities = this[PRIVATE.entities].get(entityClass)
      let serializedKey = serializeKey(primaryKey)
      entities.set(serializedKey, {
        data: clone(entityData),
        entity
      })
      Object.assign(entity, entityData)
      this[PRIVATE.deleteExtraneousFields](entity, entityData)
      return entity
    }
  }
refresh ( entity ) { if ( ! ( entity instanceof AbstractEntity ) ) { throw new TypeError ( "The entity must an AbstractEntity instance" ) } let entityClass = entity . constructor validateEntityClass ( entityClass ) let storeName = entityClass . objectStore let keyPath let primaryKey if ( this [ PRIVATE . rwTransactionRunner ] ) { return this [ PRIVATE . runTransactionOperation ] ( ( transaction ) => { let objectStore = transaction . getObjectStore ( storeName ) keyPath = objectStore . keyPath primaryKey = getPrimaryKey ( entity , keyPath ) return objectStore . get ( primaryKey ) } ) . then ( processRefreshedData . bind ( this ) ) } return this [ PRIVATE . connection ] . then ( ( database ) => { return database . runReadOnlyTransaction ( storeName , ( objectStore ) => { keyPath = objectStore . keyPath primaryKey = getPrimaryKey ( entity , keyPath ) return objectStore . get ( primaryKey ) } ) } ) . then ( processRefreshedData . bind ( this ) ) function processRefreshedData ( entityData ) { if ( ! this [ PRIVATE . entities ] . has ( entityClass ) ) { this [ PRIVATE . entities ] . set ( entityClass , new Map ( ) ) } let entities = this [ PRIVATE . entities ] . get ( entityClass ) let serializedKey = serializeKey ( primaryKey ) entities . set ( serializedKey , { data : clone ( entityData ) , entity } ) Object . assign ( entity , entityData ) this [ PRIVATE . deleteExtraneousFields ] ( entity , entityData ) return entity } }
Reloads the state of the provided entity from the database.
Reloads the state of the provided entity from the database .