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