Jump to content

MongoDB Connector - how to do an $and or $or query?


sszretter

Recommended Posts

 In iReports I have the mongodb connector installed and working, but I am having trouble getting an 'or' or 'and' query to work:

 

This works to bring back ALL records:

 

 

<queryString language="MongoDbQuery">

<![CDATA[{

 'collectionName':'Encounters' 

    }]]>

</queryString>

 

But I have all kinds of variations to actually query a field for not equal to null / not blank (I want to find all records with a BSBegin not null and not blank:

<queryString language="MongoDbQuery">

<![CDATA[{

 'collectionName':'Encounters' ,

'findQuery':{

    '$and': { 'bsBeginDT':{'$ne':null}, 'bsBeginDT':{'$ne':''}  } 

        }

    }]]>

</queryString>

 

I have tried several variations, with cury brackets around each query, square brackets around the $and criteria, etc.  

I either get iterator errors, report contains no pages or other errors.

 

 

Link to comment
Share on other sites

  • 5 months later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

$and and $or operators works with arrays rather than with maps as stated here

Here is your query modified

{
    collectionName : 'Encounters',
    findQuery : {
      $and : [
        { bsBeginDT : { $ne : null } },
        { bsBeginDT : { $ne : '' } }
      ]
    }
}

MongoDbDataSource 0.12 is published now with new features like (as you may noticed) avoiding quotes for Map keys

Please let us know how this goes for you

Eric



Post Edited by eddiaz at 02/15/2012 17:35
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...