Mongodb SyntaxError: Unexpected token } - mongodb-query

This is my query
db.courses.find({"courses"})
on my courses collection. I'm not sure what's going wrong in my syntax considering I have two brackets.
The error says
E QUERY SyntaxError: Unexpected token }

You need to past a valid JSON object to the find() method
{courses:'xxx'}
If you are trying to get all, then you just need to paste a empty braces, db.courses.find({}) or leave it blank.
Read a little more about MongoDB and the find method in the documentation.

Related

SyntaxError: unexpected EOF while parsing on MRJob

I am working with MRJob through python and when I try to create a class, I get a synthax error. It's highlighting the colon. What am I missing? Here is my code:
class Bacon_count(MRJob):
You are defining an empty class, but in an unproper way. In Python an empty class should contain a pass statement, in your case:
class Bacon_count(MRJob):
pass
Also, take into account how to define single class methods in multiple cells, if that's what you are trying to do, as it is discussed here.

Vue: (Marvel API) Error in render: "TypeError: Cannot read property 'path' of undefined"

As mentioned, I'm using the Marvel API. At mounted() I use this action:
mounted() {
this.$store.dispatch("get/getCharacter", this.$route.params.id);
},
This uses axios to call for the character object, and sends that payload to a mutation, which updates the state of character: {}. I use a getter to call the state of the character to output in my page. Everything works, the image appears and if I interpolate the string to the page, that appears as it should. However, I'm still getting the typeError. I'm creating the img like this:
<img :src="`${character.thumbnail.path}/portrait_incredible.${character.thumbnail.extension}`
So, doing this {{ character.thumbnail.path }} outputs the correct 'path' string from the object. The image loads perfectly on my computer too, but not on my Oppo phone (I've uploaded it to Netlify to check). Strangely, my friends iPhone does load the images using the Netflify link.
What am I doing wrong, and how can I make this error go away?
Thanks for any help!
I know this question is old, but I would like to give my solution since no one has answered this question. So it may help someone in future.
You can use the optional chaining operator to solve this,
The ?. operator is like the . chaining operator, except that instead of causing an error if a reference is nullish (null or undefined), the expression short-circuits with a return value of undefined. When used with function calls, it returns undefined if the given function does not exist.
See Optional chaining (?.)
character.thumbnail?.path
character.thumbnail?.extension

Incomprehensible unexpected token error in do...while loop

It's perhaps the first time I use a do...while loop. I can't figure out what's wrong with it:
const randomLetter
do {
randomLetter = String.fromCharCode(97 + 26 * Math.random() | 0)
} while (state.lettersFound.includes(randomLetter))
At line do { I'm getting some unexpected token syntax error. Why?
The syntax for declaring a constant is:
const Identifier = Initializer
The parser is expecting to see an equals sign = after the identifier (randomLetter), but instead it unexpectedly sees the keyword do.
So, the error message and the error location is correct: the unexpected token is the keyword do and the error occurs at the token do.
Note: depending on the parser, the error message is more or less helpful, e.g. I get this in Node.js 13.1.0 / V8 7.8:
Thrown:
const randomLetter
^^^^^^^^^^^^
SyntaxError: Missing initializer in const declaration
Note: this is not really about do-loops: anything that is not an equals sign = would trigger a similar syntax error.
Note: vue.js cannot possibly have anything to do with this, since it is clearly a syntax / parse error and ECMAScript (like almost all languages and certainly all mainstream languages) does not allow libraries to change the fundamental syntax of the language.

How to identify an element by classname containing curly brackets

when i try to access element:
browser.element('.object{ media }');
I get the following error message:
Error: Argument was an invalid selector (e.g. XPath/CSS).
at element(".object{ media }") - index.js:312:3
Is it possible to access elements by class name including curly brackets?
As per your question and your code trials to access desired element with classname containing curly brackets i.e. {} you can use the following solution:
XPath:
"//*[#class=\"object{ media }\"]"
Following what #DebanjanB said,
You can use something called Regular Expressions to sort issues like this out, what Debanjan has shown you is known as this.
Regular Expressions Guide
It would be useful if you read through a guide so you fully understand the code you are putting into your project, this will allow you to make better use of it later on in your testing.
All the best,
Jack

hapijs - route config 'id' attribute - won't accept string value

I'm not sure if this is a bug or not, so I'm asking here, rather than submitting a bug report.
In the documentation for the latest version of hapijs (16.1.1)
https://hapijs.com/api#serverlookupid
For server.lookup, it clearly indicates that an 'id' property can be a string.
const route = server.lookup('root');
However strings are expressively forbidden by the actual implementation code.
https://github.com/hapijs/hapi/blob/master/lib/connection.js#L340
Hoek.assert(id && typeof id === 'string', 'Invalid route id:', id);
Am I missing something here? Is this a bug, or an error in the documentation, or am I simply misunderstanding something?
It seems an strange limitation to impose. Strings are a lot more logical for a route id.
The other issue, is that in the index.d.ts, it specifically forces the use of a string parameter.
This functionality just seems completely broken. How am I supposed to use it, if when creating a route I need to use a numeric id, and then when trying to retrieve it I'm forced to use a string?
You are reading the assert backwards. The error message only displays if the assertion fails. If an id is provided it can only be of type string.