M121:Chapter 3: Core Aggregation - Combining Information RegEx

Regex shown in detailed answer after completing the lab will also match values againt following values
1747
3802
7474
2380

Although current table might not containt these values and only 747 and 380 for airplanes still it will fail as soon as any combination of the above will be added and that will not necessarily work in real life scenario.

@007_jb -> follow up form M121:Chapter 3: Core Aggregation - Combining Information

Yes, you’re right. It’s an overkill! I didn’t use Regex when I did it.

In case anyone is wondering what @Igor_05290 is talking about:

db.air_routes.aggregate([
  {
    $match: {
      $and: [
	    {airplane: /747|380/}, 
		{airplane: {$nin: ["747", "380"]}}
	  ]
    }
  },
  {
	$project: {
	  _id: 0, 
	  airplane: 1
	}
  }
]).pretty()

just wanted to let this be known in case it confuses some people

as usual @007_jb you are very helpfull, thanks for the discussion.

i have no idea how to close this topic and maybe do not have the authority so leaving with you.

Neither do I :wink: There’s a “solved” button on every post. You can use that.

1 Like