find(entityClass, primaryKey) {
    validateEntityClass(entityClass)

    if (this[PRIVATE.entities].has(entityClass)) {
      let keysToEntities = this[PRIVATE.entities].get(entityClass)
      let serializedPrimaryKey = serializeKey(primaryKey)
      if (keysToEntities.has(serializedPrimaryKey)) {
        return Promise.resolve(keysToEntities.get(serializedPrimaryKey).entity)
      }
    }

    let storeName = entityClass.objectStore

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

        return null
      })
    }

    return this[PRIVATE.connection].then((database) => {
      return database.runReadOnlyTransaction(storeName, (objectStore) => {
        return objectStore.get(primaryKey)
      })
    }).then((entityData) => {
      if (entityData) {
        return new entityClass(entityData)
      }

      return null
    })
  }
/**
   * Retrieves the entity matching the specified primary key from the database.
   *
   * The entity will not be locked in the database nor managed by this entity
   * manager if an entity manager transaction is not in progress.
   *
   * @template {T} extends AbstractEntity
   * @param {function(new: T, data: Object<string, *>)} entityClass The entity
   *        class specifying the type of entity to retrieve.
   * @param {(number|string|Date|Array)} primaryKey The primary key identifying
   *        the entity.
   * @return {Promise<?T>} A promise that will resolve to the entity, or
   *         {@code null} if the entity does not exist.
   */
Retrieves the entity matching the specified primary key from the database.
The entity will not be locked in the database nor managed by this entity
manager if an entity manager transaction is not in progress.

@template {T} extends AbstractEntity
@param {function(new: T, data: Object)} entityClass The entity
class specifying the type of entity to retrieve.
@param {(number|string|Date|Array)} primaryKey The primary key identifying
the entity.
@return {Promise} A promise that will resolve to the entity, or
null if the entity does not exist.
Retrieves the entity matching the specified primary key from the database . The entity will not be locked in the database nor managed by this entity manager if an entity manager transaction is not in progress . @template { T } extends AbstractEntity @param { function ( new : T data : Object ) } entityClass The entity class specifying the type of entity to retrieve . @param { ( number|string|Date|Array ) } primaryKey The primary key identifying the entity . @return { Promise } A promise that will resolve to the entity or null if the entity does not exist .
find(entityClass, primaryKey) {
    validateEntityClass(entityClass)
    if (this[PRIVATE.entities].has(entityClass)) {
      let keysToEntities = this[PRIVATE.entities].get(entityClass)
      let serializedPrimaryKey = serializeKey(primaryKey)
      if (keysToEntities.has(serializedPrimaryKey)) {
        return Promise.resolve(keysToEntities.get(serializedPrimaryKey).entity)
      }
    }
    let storeName = entityClass.objectStore
    if (this[PRIVATE.rwTransactionRunner]) {
      let keyPath
      return this[PRIVATE.runTransactionOperation]((transaction) => {
        let objectStore = transaction.getObjectStore(storeName)
        keyPath = objectStore.keyPath
        return objectStore.get(primaryKey)
      }).then((entityData) => {
        if (entityData) {
          return this[PRIVATE.manage](entityClass, keyPath, entityData)
        }
        return null
      })
    }
    return this[PRIVATE.connection].then((database) => {
      return database.runReadOnlyTransaction(storeName, (objectStore) => {
        return objectStore.get(primaryKey)
      })
    }).then((entityData) => {
      if (entityData) {
        return new entityClass(entityData)
      }
      return null
    })
  }
find ( entityClass , primaryKey ) { validateEntityClass ( entityClass ) if ( this [ PRIVATE . entities ] . has ( entityClass ) ) { let keysToEntities = this [ PRIVATE . entities ] . get ( entityClass ) let serializedPrimaryKey = serializeKey ( primaryKey ) if ( keysToEntities . has ( serializedPrimaryKey ) ) { return Promise . resolve ( keysToEntities . get ( serializedPrimaryKey ) . entity ) } } let storeName = entityClass . objectStore if ( this [ PRIVATE . rwTransactionRunner ] ) { let keyPath return this [ PRIVATE . runTransactionOperation ] ( ( transaction ) => { let objectStore = transaction . getObjectStore ( storeName ) keyPath = objectStore . keyPath return objectStore . get ( primaryKey ) } ) . then ( ( entityData ) => { if ( entityData ) { return this [ PRIVATE . manage ] ( entityClass , keyPath , entityData ) } return null } ) } return this [ PRIVATE . connection ] . then ( ( database ) => { return database . runReadOnlyTransaction ( storeName , ( objectStore ) => { return objectStore . get ( primaryKey ) } ) } ) . then ( ( entityData ) => { if ( entityData ) { return new entityClass ( entityData ) } return null } ) }
Retrieves the entity matching the specified primary key from the database.
Retrieves the entity matching the specified primary key from the database .