duyluonglc / lucid-mongo

Mongodb ODM for adonis framework
325 stars 61 forks source link

Error Method "$like" is not support by query builder #224

Open Nainabbas opened 5 years ago

Nainabbas commented 5 years ago

I am trying to get user where name includes some substring using 'like' parameter. This error comes Method "$like" is not support by query builder

Nainabbas commented 5 years ago

async test({ response }) { let users = await User.query() .where("fname", "like", "%nain%") .fetch(); return response.send(users); }

duyluonglc commented 5 years ago

try with regex

await User.where({ name: { $regex: new RegExp(`.*${name}.*`) } })