Wednesday, December 12, 2018

MongoDB Find


Did a stupid wee wee today by trying a syntax which looks okay in my eyes. Was wondering what went wrong. So used to using &gt to look for products or a condition for greater than.

MongoDB find option also has gt thus trying my hands on it only to appear this error.

SyntaxError: invalid property id @(shell):1:25

Frustrated, was wondering is it because there was an error in data, until I look closely at my syntax.

db.products.find({price:{&gt: 1}})

Seemingly it doesn’t look like anything is wrong, until I spotted after like 30 minutes later (I must have problem with my eyes)

Just replace that dang &gt into $gt.

Fishcakes