Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何在(Jasper Studio)的mongo DB查询中创建动态/可选筛选器(参数)_Sql_Mongodb_Jasper Reports - Fatal编程技术网

Sql 如何在(Jasper Studio)的mongo DB查询中创建动态/可选筛选器(参数)

Sql 如何在(Jasper Studio)的mongo DB查询中创建动态/可选筛选器(参数),sql,mongodb,jasper-reports,Sql,Mongodb,Jasper Reports,我正在创建一个web应用程序,它工作得很好,但最终用户需要根据它的数据创建一个报告 在报告页面上,我创建了一些txt框,用户可以在其中键入以进行筛选。那些txt框可能是空的,我需要返回数据库中的所有内容,或者可以填充一些参数。请记住,我需要将txt框内容作为参数传递给JasperServer,它们将在查询中使用 数据输入的一个例子是: txtName= empty (null), txtCity= 'Belo Horizonte' 它应该生成一份报告,记录人们在贝洛奥里藏特的

我正在创建一个web应用程序,它工作得很好,但最终用户需要根据它的数据创建一个报告

在报告页面上,我创建了一些txt框,用户可以在其中键入以进行筛选。那些txt框可能是空的,我需要返回数据库中的所有内容,或者可以填充一些参数。请记住,我需要将txt框内容作为参数传递给JasperServer,它们将在查询中使用

数据输入的一个例子是:

    txtName= empty (null), 
    txtCity= 'Belo Horizonte'
它应该生成一份报告,记录人们在贝洛奥里藏特的生活情况,无论姓名如何

我用SQL做的,效果很好。在我尝试在mongo上使用相同的逻辑后,但它不起作用。我试过使用$lt、$gt、$lte、$gte、$exist、$ne和其他聚合工具,但未能正确使用

SQL:

蒙戈:

{
    'collectionName' : 'myfirstreports',

   'findFields' : 
    {
        'nome': 1, 'numeros': 1, 'vulgo': 1, 'cidade': 1, 
        'usuResponsavelCadastro': 1, 'created_at': 1
    },

    findQuery  : 
    {
        $and: [ 
            {$or:[{ $P{city}: {$eq: null}}, {'cidade': $P{city}}]}, 
            { $or:[{$P{name}: {'$eq': null}}, {'nome': $P{name}}]}
                    ]
     }
}

我使用了以下表达:

$P{city}.equals(null)? "{ }" : "{'cidade': '$P!{city}'}"//Need to create a non prompting parameter
$P{name}.equals(null)? "{ }":  "{'nome': '$P!{name}'}"
$p!{…}参数允许我创建一个字符串形式的查询并传递给JasperSoft report

$P{city}.equals(null)? "{ }" : "{'cidade': '$P!{city}'}"//Need to create a non prompting parameter
$P{name}.equals(null)? "{ }":  "{'nome': '$P!{name}'}"