find and findOne query fails with error
See original GitHub issueRepro steps:
- Connect to a database
- Open a scrapbook
- Type any of the following queries:
db.user.findOne(<key>: <value>)
db.user.find(<key>: <value>)
- Execute the MongoDB Command
Expect:
VSCode to display the JSON for the document
Actual:
Action: cosmosDB.executeMongoCommand Error type: Error Error Message: Error near line 0, column 23, text ‘:’. Please check syntax.
Environment:
Version: 0.7.2 OS: darwin Insiders Build
Gush:
I love being able to do database stuff in Code, and it’s one of the several things I brag about to other engineers when trying to convert them 😄
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
MongoDB Node findone how to handle no results?
The problem is say I dont have any results, err is still null whether I find a result or don't. How would I...
Read more >If findOne query returns nothing throw an error #3298 - GitHub
There should be a way to define that a query like .findOne should throw and error if there were not documents matching the...
Read more >db.collection.findOne() — MongoDB Manual
Returns one document that satisfies the specified query criteria on the collection ... Although similar to the find() method, the findOne() method returns...
Read more >Mongoose v6.8.1: API docs
Mongoose.prototype.CastError(). Parameters. type «String» The name of the type. value «Any» The value that failed to cast.
Read more >MongoDB findOne Example - DigitalOcean
MongoDB findOne - Empty Query specification ... void emptyFindOne() throws UnknownHostException { // Get a new connection to the db assuming ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think you’re just missing some curly braces. Note the error
Error near line 0, column 23, text ':'. Please check syntax.
the colon is unexpected because the curlies are missing.so try
db.user.find({ "userId": "6b0ab018-0872-4a19-9698-571a106dd837" })
Find accepts a query object and you’re just passing strings separated by a colon.
Yay! Glad that solved it. 😄 Thanks for following up.