persist(entity) {
    if (!(entity instanceof AbstractEntity)) {
      throw new TypeError("The entity must be an AbstractEntity instance")
    }
    validateEntityClass(entity.constructor)

    let objectStoreName = entity.constructor.objectStore
    let objectStore = this[PRIVATE.transaction].getObjectStore(objectStoreName)
    let keyPath = objectStore.keyPath

    return new Promise((resolve, reject) => {
      objectStore.add(entity).then((primaryKey) => {
        setPrimaryKey(entity, keyPath, primaryKey)
        return entity
      }).then(resolve).catch(reject)
    }).then((entity) => {
      if (entity) {
        return this[PRIVATE.manageEntity](entity.constructor, keyPath, entity)
      }

      return null
    })
  }
/**
   * Creates the specified entity in the storage. If the entity does not have
   * its primary key set and the storage has the {@code autoIncrement} flag
   * set, the entity will have its primary key generated and set after this
   * operation completes.
   *
   * @param {AbstractEntity} entity The entity to persist in the storage.
   * @return {Promise<AbstractEntity>} A promise resolved when the entity has
   *         been persisted. The result is the persisted entity with its
   *         primary key set.
   */
Creates the specified entity in the storage. If the entity does not have
its primary key set and the storage has the  autoIncrement flag
set, the entity will have its primary key generated and set after this
operation completes.

@param {AbstractEntity} entity The entity to persist in the storage.
@return {Promise} A promise resolved when the entity has
been persisted. The result is the persisted entity with its
primary key set.
Creates the specified entity in the storage . If the entity does not have its primary key set and the storage has the autoIncrement flag set the entity will have its primary key generated and set after this operation completes . @param { AbstractEntity } entity The entity to persist in the storage . @return { Promise } A promise resolved when the entity has been persisted . The result is the persisted entity with its primary key set .
persist(entity) {
    if (!(entity instanceof AbstractEntity)) {
      throw new TypeError("The entity must be an AbstractEntity instance")
    }
    validateEntityClass(entity.constructor)
    let objectStoreName = entity.constructor.objectStore
    let objectStore = this[PRIVATE.transaction].getObjectStore(objectStoreName)
    let keyPath = objectStore.keyPath
    return new Promise((resolve, reject) => {
      objectStore.add(entity).then((primaryKey) => {
        setPrimaryKey(entity, keyPath, primaryKey)
        return entity
      }).then(resolve).catch(reject)
    }).then((entity) => {
      if (entity) {
        return this[PRIVATE.manageEntity](entity.constructor, keyPath, entity)
      }
      return null
    })
  }
persist ( entity ) { if ( ! ( entity instanceof AbstractEntity ) ) { throw new TypeError ( "The entity must be an AbstractEntity instance" ) } validateEntityClass ( entity . constructor ) let objectStoreName = entity . constructor . objectStore let objectStore = this [ PRIVATE . transaction ] . getObjectStore ( objectStoreName ) let keyPath = objectStore . keyPath return new Promise ( ( resolve , reject ) => { objectStore . add ( entity ) . then ( ( primaryKey ) => { setPrimaryKey ( entity , keyPath , primaryKey ) return entity } ) . then ( resolve ) . catch ( reject ) } ) . then ( ( entity ) => { if ( entity ) { return this [ PRIVATE . manageEntity ] ( entity . constructor , keyPath , entity ) } return null } ) }
Creates the specified entity in the storage.
Creates the specified entity in the storage .