Skip to main content

Posts

Showing posts from April, 2017

MongoDB and Nodejs Apps with Mongoose

Node.js and MongoDB are a pair made for each other. Being able to use JSON across the board and JavaScript makes development very easy. This is why you get popular stacks like the MEAN stack that uses Node, Express (a Node.js framework), MongoDB, and AngularJS. CRUD is something that is necessary in most every application out there. We have to create, read, update, and delete information all the time. Today we’ll be looking at code samples to handle CRUD operations in a Node.js, ExpressJS, and MongoDB application. We’ll use the popular Node package,  mongoose . These code samples were used to create a Node.js RESTful API since you are performing CRUD functions when creating an API. Read through that tutorial to see these commands in action. This article will be more of a reference for the various commands and their usage. What Is Mongoose? mongoose  is an object modeling package for Node that essentially works like an ORM that you would see in other languages (like Eloquent

Making It All Work Together - Controllers, Services and routes

Making It All Work Together We have defined our resources, controllers, services, and routes and included the files in our  index.html . Now let’s make them all work together. Let’s set up our Angular app to use all of our components. We will use dependency injection and set up our Angular application. // public/js/app.js angular . module ( 'sampleApp' , [ 'ngRoute' , 'appRoutes' , 'MainCtrl' , 'NerdCtrl' , 'NerdService' ] ) ; Conclusion Now we have an application that has a Node.js backend and an AngularJS frontend. We can use this foundation to build any sort of application moving forward. We can add authentication and CRUD functionality to create a good application. Also, for those looking for this project with the addition of the Jade templating engine, Florian Zemke has created a Jade version at his GitHub repo. NEXT STEPS Moving forward, I’d encourage you to take this and see if it fits your needs. The point