0

I am playing around with Lokijs to figure out if it will work for me. I have created a db of about 170K records (~500 MB size). The records have (among other keys), the following

…
authors: [
    {name: 'William Shakespeare'},
    {name: 'Ed McBain'},
    {name: 'Odom Shatner'},
    …
],
…

How do I query for all the records that have the string /m Sha/? I have tried (the obviously wrong)

const results = coll.find({
     'authors': {
           'name': {
               '$regex': /m Sha/ 
           }
     }
});

Suggestions?

punkish
  • 13,598
  • 26
  • 66
  • 101

1 Answers1

0

Found the answer at How do I query nested object by property inside an array?

The following does the job

const results = coll.find({
    'authors.name': {
        '$regex': /m Sha/ 
    }
});
punkish
  • 13,598
  • 26
  • 66
  • 101