0

I am trying to execute the query below is my query

Product.find({mobile:{contains:998888}})

I am getting error below

Could not use the provided where clause. Could not filter by mobile: A contains (i.e. string search) modifier cannot be used with a boolean or numeric attribute (it wouldn't make any sense).

I want to search number in a column which is the data type is "int". I am using MYSQL for database.

  • Do a numeric comparison instead? – Dave Newton Nov 27 '19 at 13:14
  • Can you share the code? – Sachin Bhalke Nov 27 '19 at 13:14
  • https://sailsjs.com/documentation/reference/waterline-orm/models/find – Dave Newton Nov 27 '19 at 13:34
  • I'd strongly suggest against storing a phone number in the database as an integer - [some reasoning as to why](https://stackoverflow.com/a/3483166/742129).. Here in Australia a mobile number starts with `04...`. If storing this as an integer you lose the leading 0 and it's not a valid phone number. If you store the phone number as a string (even if it only contains numeric characters) you can do your "contains" style queries, and MySQL won't screw up your input. – nahanil Dec 04 '19 at 06:03
  • It is just an example. I want to search by number. Number search is faster than string search. – Sachin Bhalke Dec 19 '19 at 06:08

1 Answers1

0

I believe you want the in operator. I doubt there's going to be any way to do substring matching on non-string values within the ORM.

https://sailsjs.com/documentation/concepts/models-and-orm/query-language#?in

Nathan Hawks
  • 557
  • 4
  • 14