Why must I use + in mongoDB query

Julian Kohann

I am doing the learnyoumongo tutorials to learn mongoDB.

On the third excercise (the find tutorial) I couldn't get it to work until i just found the solution. My mistake was that the query needed a "+" in front of the argument.

so db.coll.find({ $gt: process.argv[2] }) did not work, but { $gt: +process.argv[2] } did.

Perhaps this is a stupid question, but what is that plus sign, and when would I use it?

Also does it play a role in regular javascript?

Explosion Pills

The + in this context is an implicit cast to a number. process.argv[2] will be a string. The + is simply a quick, easy, and generally safe way to cast it to a number. $gt expects a number for comparison rather than a string -- even a numeric string.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Why I'm getting the error "Must provide query string." express-graphql?

分類Dev

Why I'm getting the error "Must provide query string." express-graphql?

分類Dev

Why I must use `@RequestParam` annotation on implementation class instead of interface class only?

分類Dev

Why I must use `@RequestParam` annotation on implementation class instead of interface class only?

分類Dev

Operation must use an Updateable Query / SQL - VBA

分類Dev

how to use update query in mongoDb?

分類Dev

how to use update query in mongoDb?

分類Dev

Use shell variables in MongoDB query

分類Dev

How to use nested mongoDB query to calculate percentage?

分類Dev

Should I use scan or query?

分類Dev

I want to use this query as an arrayformula

分類Dev

How I query array type via Mongodb

分類Dev

When querying MongoDB should we use Query or Query<T>?

分類Dev

Why must I enter a passphrase to encrypt a file with my own key?

分類Dev

Why can I use 'this' in methods

分類Dev

Why postgresql does not use index in this query

分類Dev

Why am I getting this deprecated warning?! MongoDB

分類Dev

how to write this query in codeigniter, i send my id to the model, but this query must be writen good in model

分類Dev

Mysql query is not working but i could not guess why

分類Dev

Android Retrofit: URL query string "text={userInput}&key={apiKey}" must not have replace block. For dynamic query parameters use @Query

分類Dev

Node API MongoDB Query - How can I return the mongoDB query to the client?

分類Dev

Can I use UseCSharpNullComparisonBehavior for a single query?

分類Dev

Can I use temporary value in sql query

分類Dev

how to use sum, multiply, divide and group by aggregation in single mongodb query

分類Dev

How to use an external variable in MongoDB 'where' query via Javascript?

分類Dev

MongoDB Aggregation: Use field value of current document in $match $or query

分類Dev

$or query in mongodb

分類Dev

How do I find and update the lowest values for a field in a mongodb query?

分類Dev

Android DialogFragment: can I re-use, or must I new up another?

Related 関連記事

  1. 1

    Why I'm getting the error "Must provide query string." express-graphql?

  2. 2

    Why I'm getting the error "Must provide query string." express-graphql?

  3. 3

    Why I must use `@RequestParam` annotation on implementation class instead of interface class only?

  4. 4

    Why I must use `@RequestParam` annotation on implementation class instead of interface class only?

  5. 5

    Operation must use an Updateable Query / SQL - VBA

  6. 6

    how to use update query in mongoDb?

  7. 7

    how to use update query in mongoDb?

  8. 8

    Use shell variables in MongoDB query

  9. 9

    How to use nested mongoDB query to calculate percentage?

  10. 10

    Should I use scan or query?

  11. 11

    I want to use this query as an arrayformula

  12. 12

    How I query array type via Mongodb

  13. 13

    When querying MongoDB should we use Query or Query<T>?

  14. 14

    Why must I enter a passphrase to encrypt a file with my own key?

  15. 15

    Why can I use 'this' in methods

  16. 16

    Why postgresql does not use index in this query

  17. 17

    Why am I getting this deprecated warning?! MongoDB

  18. 18

    how to write this query in codeigniter, i send my id to the model, but this query must be writen good in model

  19. 19

    Mysql query is not working but i could not guess why

  20. 20

    Android Retrofit: URL query string "text={userInput}&key={apiKey}" must not have replace block. For dynamic query parameters use @Query

  21. 21

    Node API MongoDB Query - How can I return the mongoDB query to the client?

  22. 22

    Can I use UseCSharpNullComparisonBehavior for a single query?

  23. 23

    Can I use temporary value in sql query

  24. 24

    how to use sum, multiply, divide and group by aggregation in single mongodb query

  25. 25

    How to use an external variable in MongoDB 'where' query via Javascript?

  26. 26

    MongoDB Aggregation: Use field value of current document in $match $or query

  27. 27

    $or query in mongodb

  28. 28

    How do I find and update the lowest values for a field in a mongodb query?

  29. 29

    Android DialogFragment: can I re-use, or must I new up another?

ホットタグ

アーカイブ