search with multiple field in node js mongodb

Solutions on MaxInterview for search with multiple field in node js mongodb by the best coders in the world

showing results for - "search with multiple field in node js mongodb"
Vincent
05 Jun 2019
1> db.test.find({$or: [{Description: {$regex: '^225/65R16'}, Brand: {$regex: '^Hankook'}}]})
2{ "Description" : "225/65R16 71T K715", "Brand" : "Hankook", "Ref" : 123455 }
3{"Description" : "225/65R16 94T", "Brand" : "Hankook", "Ref" : 123455 }
4
5> db.test.find({$or: [{Description: {$regex: '^225'}, Brand: {$regex: '^Han'}}]})
6{ "Description" : "225/65R16 71T K715", "Brand" : "Hankook", "Ref" : 123455 }
7{ "Description" : "225/65R16 94T", "Brand" : "Hankook", "Ref" : 123455 }
Lucia
07 Mar 2016
1db.test.find({
2$or:[
3    {
4        $and: [
5                {'stocknumber':12346},
6                {'model':'bmx'},
7                {'make':2002},
8                {'rego':'KA01HG6268'},
9                {'adate':'2017-10-01T05:07:10.969Z'},
10                {'cdate':'2017-10-01T05:07:10.969Z'}
11            ]
12    },
13    {
14        $and: [
15                {'stocknumber':12347},
16                {'model':'bmy'},
17                {'make':2003}
18            ]
19
20    }
21]
22}).pretty()