How to get all the values that contains part of a string using mongoose find?

前端 未结 2 1973
故里飘歌
故里飘歌 2020-12-12 19:13

I have the following problem retrieving data from MongoDB using mongoose.

Here is my Schema:

const BookSchema = new Schema(
    {
        _id:Number,         


        
2条回答
  •  佛祖请我去吃肉
    2020-12-12 19:37

    Find the posts with title containing : cool , and case insensitive match: (Very Cool have cool also)

    const s = 'cool'
    const regex = new RegExp(s, 'i') // i for case insensitive
    Posts.find({title: {$regex: regex}})
    

提交回复
热议问题