0

The document looks like:

{
    "_id" : ObjectId("5c11389782c3c3751def6a68"),
    "\"dname\"" : "\"W6PJBu7wC0Demyl86pd8Um5NHk3ukqsdtVA6                       \""
}

I've searched a lot and found that I can write it as: /. For example, I need to get all document where dname starts with c, for this I do:

db.getCollection('flat').find({"\"dname\"" : "\"c/"})

Also I've tried this:

db.getCollection('flat').find({"\"dname\"" : "/^\"c/"})

but it does not work. What I do wrong?

J. Doe
  • 521
  • 4
  • 15

1 Answers1

2

You need to use regexes

For example, to find records with dname starting with c: db.getCollection('flat').find({"\"dname\"" : /^\"c/})

ack_inc
  • 1,015
  • 7
  • 13