Exclude Mongo fields based on regex Exclude Mongo fields based on regex mongoose mongoose

Exclude Mongo fields based on regex


I solved this by using $not in mongodb

    {    "_id" : "1",    "name" : "label123"}/* 2 */{    "_id" : "2",    "name" : "sample"}db.getCollection('things').find({name:{$not:/^label/}})

Output:{ "_id" : "2", "name" : "sample" }