How can I combine the $not Logical Query Operator in conjunction with other Comparison Query Operators to get a more specific yield?

SirBT

This is the result of my document after query

players.find().fetch():

{name:'john',     sessionIDz:"utFmxmRioDiZdmwGJ"},
{name:'jessica',  sessionIDz:"FmwgXvxHZmuAwSzpe"},
{name:'Liz',      sessionIDz:"FmwgXvxHZmuAwSzpe"},
{name:'Ericsson', sessionIDz:"FmwgXvxHZmuAwSzpe", Winner: 1},
{name:'Anderson', sessionIDz:"utFmxmRioDiZdmwGJ"}

After query:

players.find( { Winner: { $not: { $gte: 1 } } } ).fetch()

Yeilds:

{name:'Anderson', sessionIDz:"utFmxmRioDiZdmwGJ"},
{name:'john', sessionIDz:"utFmxmRioDiZdmwGJ"},
{name:'jessica', sessionIDz:"FmwgXvxHZmuAwSzpe"},
{name:'Liz', sessionIDz:"FmwgXvxHZmuAwSzpe"}

Which is fine. But now, how do I further narrow down the yield to all documents containing fields sessionIDz:"FmwgXvxHZmuAwSzpe", as illustrated below:

{name:'jessica', sessionIDz:"FmwgXvxHZmuAwSzpe"},
{name:'Liz', sessionIDz:"FmwgXvxHZmuAwSzpe"}

Is there a way I can combine the $not Logical Query Operator in conjunction with other Comparison Query Operators to achieve this yield?.

I have tried the query below, but fail to get the desired result:

player.find({Winner: { $not: { $gte: 1 }}}, {sessionIDz: { $eq:"FmwgXvxHZmuAwSzpe" } }).fetch()

Your help is much appreciated.

chridam

You need to include the condition within the same query object. Because the logic NOT greater than or equal to

{ "$not": { "$gte": 1 } }

is just the same as LESS than

{ "$lt": 1 }

your query may be simplified to

player.find({
    "Winner": { "$lt": 1 }, 
    "sessionIDz": "FmwgXvxHZmuAwSzpe" 
}).fetch()

or if you want to query where the Winner field does not exist, the query is

player.find({
    "Winner": { "$exists": false }, 
    "sessionIDz": "FmwgXvxHZmuAwSzpe" 
}).fetch()

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to filter a query string with comparison operators in Express

From Dev

How can I combine query_string and terms query?

From Dev

How can I rewrite this query to be more readable?

From Dev

How can I more efficiently perform a query that returns how many times an ID appears in two other tables?

From Dev

how do i get a rails WHERE query to be more specific? "Like" works, = doesn't

From Dev

MongoDB in Go (golang) with mgo: how to use logical operators to query?

From Dev

PHP Query/Comparison Method with Operators

From Dev

How can i optimize this mysql query ? i use IN() operator

From Dev

How can I combine these two SQL queries into a single query?

From Dev

Can logical operator be used with in ternary operators in PHP

From Dev

How to combine group by, where and logical operators?

From Dev

How can I get the complement in this SQL query?

From Dev

How can I get the icons by content query?

From Dev

how get query with >= =< more filters

From Dev

How can I use the Like Operator with a Parameter in a SQLite query?

From Dev

How can i make OR operator in query params in django rest framework

From Dev

How can i make OR operator in query params in django rest framework

From Dev

For an SQLAlchemy query, how to combine ilike search operator with in_ operator?

From Dev

batch file reg query with logical operators (NOT)

From Dev

batch file reg query with logical operators (NOT)

From Dev

Parsing query string in Node to allow logical operators

From Dev

Can I put logical operators in document.querySelectorAll? If so, how?

From Dev

How can I make this search query more efficient?

From Dev

Can I combine a foreach and a LINQ query into one?

From Dev

Logical comparison of boolean literals in coldfusion query of queries?

From Dev

Combine multiple logical operators

From Dev

Combine logical operators in C

From Dev

elasticsearch: match query can get result, but more like query can not

From Dev

How can I trigger an email or other notification based on a BigQuery query?

Related Related

  1. 1

    How to filter a query string with comparison operators in Express

  2. 2

    How can I combine query_string and terms query?

  3. 3

    How can I rewrite this query to be more readable?

  4. 4

    How can I more efficiently perform a query that returns how many times an ID appears in two other tables?

  5. 5

    how do i get a rails WHERE query to be more specific? "Like" works, = doesn't

  6. 6

    MongoDB in Go (golang) with mgo: how to use logical operators to query?

  7. 7

    PHP Query/Comparison Method with Operators

  8. 8

    How can i optimize this mysql query ? i use IN() operator

  9. 9

    How can I combine these two SQL queries into a single query?

  10. 10

    Can logical operator be used with in ternary operators in PHP

  11. 11

    How to combine group by, where and logical operators?

  12. 12

    How can I get the complement in this SQL query?

  13. 13

    How can I get the icons by content query?

  14. 14

    how get query with >= =< more filters

  15. 15

    How can I use the Like Operator with a Parameter in a SQLite query?

  16. 16

    How can i make OR operator in query params in django rest framework

  17. 17

    How can i make OR operator in query params in django rest framework

  18. 18

    For an SQLAlchemy query, how to combine ilike search operator with in_ operator?

  19. 19

    batch file reg query with logical operators (NOT)

  20. 20

    batch file reg query with logical operators (NOT)

  21. 21

    Parsing query string in Node to allow logical operators

  22. 22

    Can I put logical operators in document.querySelectorAll? If so, how?

  23. 23

    How can I make this search query more efficient?

  24. 24

    Can I combine a foreach and a LINQ query into one?

  25. 25

    Logical comparison of boolean literals in coldfusion query of queries?

  26. 26

    Combine multiple logical operators

  27. 27

    Combine logical operators in C

  28. 28

    elasticsearch: match query can get result, but more like query can not

  29. 29

    How can I trigger an email or other notification based on a BigQuery query?

HotTag

Archive