'use strict';

const AbstractRepository = require('./AbstractRepository');

/**
 * @class AccountRepository
 */
class AccountRepository extends AbstractRepository {
  /**
   * @inheritDoc
   */
  getSchemaDefinition() {
    return {
      email: {
        type: String,
        unique: true,
        required: true
      },
      username: {
        type: String,
        unique: true,
        required: true
      },
      passwordHash: String,
    };
  }

  /**
   * @param email
   * @returns {Promise}
   */
  findOneByEmail(email) {
    return this.findOne({
      email: email,
    });
  }

  /**
   * Find an account by its username.
   *
   * @param {string} username
   * @return {Promise}
   */
  findOneByUsername(username) {
    return this.findOne({
      username: username,
    }, callback);
  }
}

module.exports = AccountRepository;

'use strict';

const BaseRepository = require('@gfcc/mongo-tenant-repository/BaseRepository');

/**
 * @class AccountRepository
 */
class AccountRepository extends BaseRepository {
  /**
   * @inheritDoc
   */
  getSchemaDefinition() {
    return {
      email: {
        type: String,
        unique: true,
        required: true
      },
      username: {
        type: String,
        unique: true,
        required: true
      },
      passwordHash: String,
    };
  }

  /**
   * @param email
   * @param callback
   * @returns {AccountRepository}
   */
  findOneByEmail(email, callback) {
    this.findOne({
      email: email,
    }, callback);

    return this;
  }

  /**
   * Find an account by its usernam.
   *
   * @param {string} username
   * @param {function} callback
   * @return {AccountRepository}
   */
  findOneByUsername(username, callback) {
    this.findOne({
      username: username,
    }, callback);

    return this;
  }
}

module.exports = AccountRepository;

--- 
+++ 
@@ -1,11 +1,11 @@
 'use strict';
 
-const BaseRepository = require('@gfcc/mongo-tenant-repository/BaseRepository');
+const AbstractRepository = require('./AbstractRepository');
 
 /**
  * @class AccountRepository
  */
-class AccountRepository extends BaseRepository {
+class AccountRepository extends AbstractRepository {
   /**
    * @inheritDoc
    */
@@ -27,30 +27,24 @@
 
   /**
    * @param email
-   * @param callback
-   * @returns {AccountRepository}
+   * @returns {Promise}
    */
-  findOneByEmail(email, callback) {
-    this.findOne({
+  findOneByEmail(email) {
+    return this.findOne({
       email: email,
-    }, callback);
-
-    return this;
+    });
   }
 
   /**
-   * Find an account by its usernam.
+   * Find an account by its username.
    *
    * @param {string} username
-   * @param {function} callback
-   * @return {AccountRepository}
+   * @return {Promise}
    */
-  findOneByUsername(username, callback) {
-    this.findOne({
+  findOneByUsername(username) {
+    return this.findOne({
       username: username,
     }, callback);
-
-    return this;
   }
 }
 
Migrate account repository to promise based version.
