I use this manually db.employees.find({Name: /^S/}); and db.employees.find({Name: /^R/}); to find the starts letter of "S" and "R",
is their any way to use the two starts letter in one function?
You can use | pipe sign to put or condition in regex,
db.employees.find({
Name: /^S|^R/
})
Playground
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With