Sign In Register

How can we help you today?

Start a new topic
Answered

No sql query for users with private data

Hello To all!
i am trying to find a way to do a noSql Query to find the sum of the players that have private data. 
Any ideas?
Thanks in advance!


Best Answer

Hi Sotiris,


You can get the number of players with private data bysupplying a query in the 'Count' tab:


{"privateData":{$gt:{}}}


Try this out and let us know how it works for you.


Regards,

Vinnie


Answer

Hi Sotiris,


You can get the number of players with private data bysupplying a query in the 'Count' tab:


{"privateData":{$gt:{}}}


Try this out and let us know how it works for you.


Regards,

Vinnie

Hello Vinnie!
That work like a charm, Thanks a lot!


can you provide some info on the whole $gt and how that provide the result i needed?


Sure. The greater than operator works in this case because mongo's sort order will place empty objects before non-empty ones. You could also use the not equal operator:


{"privateData":{$ne:{}}}


which would work for this field, but in general $gt is more accurate as $ne will also return documents where the value has been set to null.


Regards,

Vinnie

Not working for me.

I get "Error parsing JSON. Please use valid JSON, including double-quotes on object keys."


I was trying {"email":{$ne:{}}} and {"email":{$ne:null}}

That I am doing wrong?

Sergi you have to put even the '$ne' in quotes. Only valid JSON works, and since it's not in quotes, it's not a string or any other valid JSON type (like number/array/object)

Login to post a comment