def update_col(input, **params):
    """
    Updates document with value from another document/collection/constant
    :param input:
    :param params:
    :return:
    """
    PARAM_TARGET = 'target'
    PARAM_UPDATE = 'update'
    SOURCE_TYPE = 'src.type'
    SOURCE_COL = 'src.col'
    SOURCE_FIELD = 'src.field'
    DEST_FIELD = 'dest.field'
    SOURCE_TYPE_DOC = 'doc'
    SOURCE_TYPE_CONST = 'const'
    CONST_VALUE = 'const.value'

    update_list = params.get(PARAM_UPDATE)
    res = input[params.get(PARAM_TARGET)] if PARAM_TARGET in params else input
    for row in res:
        for update_desc in update_list:
            if update_desc[SOURCE_TYPE] == SOURCE_TYPE_DOC:
                row[update_desc[DEST_FIELD]] = input[update_desc[SOURCE_COL]][update_desc[SOURCE_FIELD]]
            elif update_desc[SOURCE_TYPE] == SOURCE_TYPE_CONST:
                row[update_desc[DEST_FIELD]] = update_desc[CONST_VALUE]
    return res