Skip to content

Instantly share code, notes, and snippets.

@hgcummings
Last active January 1, 2016 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hgcummings/9abbcffe851373377081 to your computer and use it in GitHub Desktop.
Save hgcummings/9abbcffe851373377081 to your computer and use it in GitHub Desktop.
Script to insert 2016 UK bank holidays into a MongoDB database
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