Last active
January 1, 2016 20:56
-
-
Save hgcummings/9abbcffe851373377081 to your computer and use it in GitHub Desktop.
Script to insert 2016 UK bank holidays into a MongoDB database
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.holidays.insert({ name: "New Year's Day", date: ISODate("2016-01-01") }); | |
db.holidays.insert({ name: "Good Friday", date: ISODate("2016-03-25") }); | |
db.holidays.insert({ name: "Easter Monday", date: ISODate("2016-03-28") }); | |
db.holidays.insert({ name: "Early May bank holiday", date: ISODate("2016-05-02") }); | |
db.holidays.insert({ name: "Spring bank holiday", date: ISODate("2016-05-30") }); | |
db.holidays.insert({ name: "Summer bank holiday", date: ISODate("2016-08-29") }); | |
db.holidays.insert({ name: "Boxing Day", date: ISODate("2016-12-26") }); | |
db.holidays.insert({ name: "Christmas Day", date: ISODate("2016-12-27"), substitute_for: ISODate("2016-12-25") }); | |
db.holidays.aggregate([{ $project: { name: true, original_date: { $ifNull: ["$substitute_for", "$date"] } } }, { $sort: { original_date: 1} }]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment