This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.createView("user_data_list", "personal_info", [ | |
{ | |
$unset: [ | |
"_id", | |
"mobile", | |
"passport_number" | |
] | |
} | |
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_id | name | mobile | passport_number | ||
---|---|---|---|---|---|
59b99db9cfa9a34dcd7885bf | andrea_le@fakegmail.com | Andrea Le | 1234569874 | P987456 | |
59b99db4cfa9a34dcd7885b7 | anthony_cline@fakegmail.com | Anthony Cline | 9874563210 | P741259 | |
59b99dd8cfa9a34dcd7885f8 | emily_ellis@fakegmail.com | Emily Ellis | 6987745279 | P147963 | |
59b99dddcfa9a34dcd788604 | teresa_thomas@fakegmail.com | Teresa Thomas | 5896321478 | P896324 | |
59b99ddfcfa9a34dcd78860a | shawn_mccormick@fakegmail.com | Shawn Mccormick | 2589631478 | P654987 | |
59b99deecfa9a34dcd788630 | jason_smith@fakegmail.com | Jason Smith | 7896325871 | P159357 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cast" : [ | |
"Tom Cruise", | |
"Brad Pitt", | |
"Daniel Craig" | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.project_data.aggregate([ | |
{ | |
$project: { | |
"cast": ["Tom Cruise", "Brad Pitt", "Daniel Craig"], | |
"_id": 0 | |
} | |
} | |
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.project_data.aggregate([ | |
{ | |
$project: { | |
"cast": ["Tom Cruise", "Brad Pitt", "Daniel Craig"], | |
"_id": 0 | |
} | |
} | |
]).pretty() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.project_data.aggregate([ | |
// Stage - 1 | |
{ | |
$set: { | |
"cast": ["Tom Cruise", "Brad Pitt", "Daniel Craig"] | |
} | |
}, | |
// Stage - 2 | |
{ | |
$unset: [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title" : "The Last Command", | |
"plot" : "A former Imperial Russian general and cousin of the Czar ends up in Hollywood as an extra in a movie directed by a former revolutionary.", | |
"rated" : "BAD", // modified existing field | |
"language" : "Russian", | |
"year" : 1928.0, | |
"poster" : "https://m.media-amazon.com/images/M/MV5BMTg2Mjg3MDI5OF5BMl5BanBnXkFtZTgwMjMzMDMyMjE@._V1_SY1000_SX677_AL_.jpg", | |
"director" : "Josef von Sternberg", | |
"awards" : { | |
"wins" : 2.0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.project_data.aggregate([ | |
// Stage - 1 | |
{ | |
$set: { | |
"rated": "BAD", // Modify exisiting field | |
"budget": "5M USD" // Add new field | |
} | |
}, | |
// Stage - 2 | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"card_name" : "Mx. Xxx Doe", | |
"card_num" : "XXXXXXXXXXXX3456", | |
"card_expiry" : ISODate("2023-09-14T21:39:37.512+0000"), | |
"card_sec_code" : "869", | |
"card_type" : "CREDIT" | |
} | |
{ | |
"card_name" : "Mx. Xxx Smith", | |
"card_num" : "XXXXXXXXXXXX7654", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.payment.aggregate([ | |
// Stage - 1 | |
{ | |
$set: { | |
"card_name": { | |
// Partially Obfuscate card name to last name | |
$regexFind: {"input": "$card_name", "regex": /(\S+)$/} | |
}, | |
// Obfuscate first 12 digits card number and only retain last 4 digits | |
"card_num": {$concat: [ |