Q:

Mongolite substring query

In my collection I want to filter out all documents having a title that starts with "Once". Implementing this query in MongoDB Compass works fine
query = '{"title" : /^((?!Once).)/i }'

but trying to do the same in R with mongolite returns the error:

Invalid JSON object.

What do I need to change?

A:

I believe in Mongolite you can avoid that error using MongoDB's $regex with " instead of \ :
query = '{"title": {"$regex": "^((?!Once).)" , "$options": "i"}}'

