constructor(file, options) {

        let filePath = file;

        options = assert(options, {
            debug: npm.utils.isDev(),
            minify: (options && options.compress && options.minify === undefined) ? true : undefined,
            compress: undefined,
            params: undefined,
            noWarnings: undefined
        });

        if (npm.utils.isText(filePath) && !npm.path.isAbsolute(filePath)) {
            filePath = npm.path.join(npm.utils.startDir, filePath);
        }

        const {usedPath} = QueryFile.instance;

        // istanbul ignore next:
        if (!options.noWarnings) {
            if (filePath in usedPath) {
                usedPath[filePath]++;
                ColorConsole.warn(`WARNING: Creating a duplicate QueryFile object for the same file - \n    ${filePath}\n${npm.utils.getLocalStack(2, 3)}\n`);
            } else {
                usedPath[filePath] = 0;
            }
        }

        const _inner = {
            file,
            filePath,
            options,
            sql: undefined,
            error: undefined,
            ready: undefined,
            modTime: undefined
        };

        super(_inner);

        this.prepare();
    }
@class QueryFile
@description

Represents an external SQL file. The type is available from the library's root: `pgp.QueryFile`.

Reads a file with SQL and prepares it for execution, also parses and minifies it, if required.
The SQL can be of any complexity, with both single and multi-line comments.

The type can be used in place of the `query` parameter, with any query method directly, plus as `text` in {@link PreparedStatement}
and {@link ParameterizedQuery}.

It never throws any error, leaving it for query methods to reject with {@link errors.QueryFileError QueryFileError}.

**IMPORTANT:** You should only create a single reusable object per file, in order to avoid repeated file reads,
as the IO is a very expensive resource. If you do not follow it, you will be seeing the following warning:
`Creating a duplicate QueryFile object for the same file`, which signals a bad-use pattern.

@param {string} file
Path to the SQL file with the query, either absolute or relative to the application's entry point file.

If there is any problem reading the file, it will be reported when executing the query.

@param {QueryFile.Options} [options]
Set of configuration options, as documented by {@link QueryFile.Options}.

@returns {QueryFile}

@see
{@link errors.QueryFileError QueryFileError},
{@link QueryFile#toPostgres toPostgres}

@example
// File sql.js

// Proper way to organize an sql provider:
//
// - have all sql files for Users in ./sql/users
// - have all sql files for Products in ./sql/products
// - have your sql provider module as ./sql/index.js

const {QueryFile} = require('pg-promise');
const {join: joinPath} = require('path');

// Helper for linking to external query files:
function sql(file) {
    const fullPath = joinPath(__dirname, file); // generating full path;
    return new QueryFile(fullPath, {minify: true});
}

module.exports = {
    // external queries for Users:
    users: {
        add: sql('users/create.sql'),
        search: sql('users/search.sql'),
        report: sql('users/report.sql'),
    },
    // external queries for Products:
    products: {
        add: sql('products/add.sql'),
        quote: sql('products/quote.sql'),
        search: sql('products/search.sql'),
    }
};

@example
// Testing our SQL provider

const db = require('./db'); // our database module;
const {users: sql} = require('./sql'); // sql for users;

module.exports = {
    addUser: (name, age) => db.none(sql.add, [name, age]),
    findUser: name => db.any(sql.search, name)
};