how do I create a “like” filter view in couchdb

前端 未结 7 836
北海茫月
北海茫月 2020-12-30 03:25

Here\'s an example of what I need in sql:

SELECT name FROM employ WHERE name LIKE %bro%

How do I create view li

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-30 04:13

    You can use regular expressions. As per this table you can write something like this to return any id that contains "SMS".

    {
       "selector": {
          "_id": {
             "$regex": "sms"
          }
       }
    }
    

    Basic regex you can use on that includes

    "^sms" roughly to LIKE "%sms"
    "sms$" roughly to LIKE "sms%"
    

    You can read more on regular expressions here

提交回复
热议问题