"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var MongoDriver_1 = require("../driver/mongodb/MongoDriver");
var LiteralRepository_1 = require("./LiteralRepository");
var LiteralTreeRepository_1 = require("./LiteralTreeRepository");
var LiteralMongoRepository_1 = require("./LiteralMongoRepository");
/**
 * Factory used to create different types of repositories.
 */
var RepositoryFactory = /** @class */ (function () {
    function RepositoryFactory() {
    }
    // -------------------------------------------------------------------------
    // Public Methods
    // -------------------------------------------------------------------------
    /**
     * Creates a repository.
     */
    RepositoryFactory.prototype.create = function (manager, metadata, queryRunner) {
        if (metadata.treeType) {
            // NOTE: dynamic access to protected properties. We need this to prevent unwanted properties in those classes to be exposed,
            // however we need these properties for internal work of the class
            return LiteralTreeRepository_1.createLiteralTreeRepository({
                manager: manager,
                metadata: metadata,
                queryRunner: queryRunner,
            });
        }
        else {
            // NOTE: dynamic access to protected properties. We need this to prevent unwanted properties in those classes to be exposed,
            // however we need these properties for internal work of the class
            if (manager.connection.driver instanceof MongoDriver_1.MongoDriver) {
                return LiteralMongoRepository_1.createLiteralMongoRepository({
                    manager: manager,
                    metadata: metadata,
                    queryRunner: queryRunner,
                });
            }
            else {
                return LiteralRepository_1.createLiteralRepository({
                    manager: manager,
                    metadata: metadata,
                    queryRunner: queryRunner,
                });
            }
        }
    };
    return RepositoryFactory;
}());
exports.RepositoryFactory = RepositoryFactory;

//# sourceMappingURL=RepositoryFactory.js.map
