Mongoose text-search with partial string

前端 未结 2 1837
北海茫月
北海茫月 2020-12-31 07:32

Hi i\'m using mongoose to search for persons in my collection.

/*Person model*/
{
    name: {
       first: String,
       last: String
             


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-31 07:34

    regex can help you with this.

    Person.find({ "name": { "$regex": "Alex", "$options": "i" } },
    function(err,docs) { 
    });
    

提交回复
热议问题