1

I would like to find records with username LIKE '%abc%' using mongoDB syntax via Sails model native. How to do my issue?

Thanh Dao
  • 1,218
  • 2
  • 16
  • 43
  • I get a param called "key", and I need to push the value of "key" into regex string. I think it is impossible, so that I ask this question for other ideas. – Thanh Dao Sep 18 '15 at 10:32
  • 1
    How about showing what you have tried? Or perhaps `var query={ "field": { "$regex": key } }` Which is basically `LIKE '%key%'` with variable substitution of course. – Blakes Seven Sep 18 '15 at 10:34
  • Hehe, I think I tried less. Your ex is great. Thanks a lot! – Thanh Dao Sep 18 '15 at 10:49

0 Answers0