/*
function that manage the call to the constraintsToQuery function. This part is listening on three event
returned by the constraintsToQuery event: "docsFound", "noDocsFound" and "errorOnConstraints"
@constraints : constraints to check
@connectType : specify wich connection type
function constraintsCall(constraints, connectType) {
    let emitterCall = new EventEmitter();
    // if docs found in couchDB database
    constraintsToQuery(constraints).on('docsFound', (docsResults) => {
        logger_1.logger.log('info', `Found ${docsResults.docs.length} docs for those constraints from ${connectType} request`);
        logger_1.logger.log('debug', `Doc list found \n ${JSON.stringify(docsResults)}`);
        logger_1.logger.log('debug', `constraints: ${JSON.stringify(constraints)}`);
        emitterCall.emit(`${connectType}Succeed`, docsResults.docs);
    })
        // if docs not found in couchDB database
        .on('noDocsFound', (docsResults) => {
        logger_1.logger.log('info', `No docs founds for constraints`);
        logger_1.logger.log('debug', `constraints: \n ${JSON.stringify(constraints)}`);
        emitterCall.emit(`${connectType}NoResults`, docsResults.docs);
    })
        // if an error occured
        .on('errorOnConstraints', (err) => {
        logger_1.logger.log('warn', `Constraints are empty or not in the right format`);
        emitterCall.emit(`${connectType}Failed`, err);
    });
    return emitterCall;
}