CRUD Operations with MongoDB & Mongoose

Today we are going to take a look at how we can save data to a mongo database using mongoose. By using mongoose, we are able to model data in our application very cleanly and abstract away low-level mongo operations. Mongoose also gives us the ability to model the data in our applications easily. We…

Loading JSON files in Angular 2

I have been using the Angular 2 Webpack Starter on github as a base for my Angular 2 applications. In order to deploy your Angular 2 application we need to package it for production by running the following command

This bundles the app up and creates a dist directory where the app will be…

Angular 2 Keyboard Events

Angular 2 allows us to listen to keyboard events by using the @HostListener decorator. The @HostListener decorator allows us to listen to events that are emitted by an element. In other words, @HostListener allows us to bind to an element and react to specific events. Lets use the @HostListener decorator to listen to keyboard events…

Copying (duplicating) Documents (Rows) in MongoDB

Duplicating a record in MongoDB can be accomplished in just a couple of steps. First, you’ll need to identify the records that you want to duplicate and obtain a cursor. Then, you will need to iterate over the records in the cursor and insert them. In the example below we will find all records in…