Case Insensitive search with $in

后端 未结 6 1414
没有蜡笔的小新
没有蜡笔的小新 2020-12-15 05:46

How to search a column in a collection in mongodb with $in which includes an array of elements for search and also caseInsensitive matching of thos

6条回答
  •  情话喂你
    2020-12-15 06:43

    This is pretty simple

    const sampleData = [
      RegExp("^" + 'girl' + "$", 'i'),
      RegExp("^" + 'boy' + "$", 'i')
    ];
    const filerObj = { gender : {$in : sampleData}};
    

提交回复
热议问题