import { MongoDriver } from "../driver/mongodb/MongoDriver";
import { createLiteralRepository } from "./LiteralRepository";
import { createLiteralTreeRepository } from "./LiteralTreeRepository";
import { createLiteralMongoRepository } from "./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 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) {
                return createLiteralMongoRepository({
                    manager: manager,
                    metadata: metadata,
                    queryRunner: queryRunner,
                });
            }
            else {
                return createLiteralRepository({
                    manager: manager,
                    metadata: metadata,
                    queryRunner: queryRunner,
                });
            }
        }
    };
    return RepositoryFactory;
}());
export { RepositoryFactory };

//# sourceMappingURL=RepositoryFactory.js.map
