Node.js

Handlebars : A step ahead

In the previous blog on Handlebars, we learnt the basic concept of handlebars and how to use them in your web applications. Now we will extend our knowledge, a bit more and see how we can use and create helper methods in handlebars to have more flexibility on data. Predefined/Built-in Helper methods: There are a number of built in...

by Rishabh Dixit
Tag: nodejs
18-Mar-2015

Node.js

High performance find query using lean() in mongoose

Lets start with a basic find query in mongoose and observe its execution time. [js] Event.find({'schedule.closing': {'$gte': +new Date()}}, {}, {limit:20, skip:0} ).exec(function (err, events){ ........ ........ } ); [/js] In my last project on Nodejs, I have used the above query to fetch the events...

by Sakshi Tyagi
Tag: nodejs
13-Feb-2015

Technology

Check Global Object Pollution using global-object-guard

JavaScript is language for Ninjas some time mistake happens by Ninja also which slow down our Node Application, because unknowingly we are dynamically creating the property on GLOBAL objects or some time we get stuck in some closure issue's which are not easy to trace and becomes a memory leak for the application. These are the common...

by Kashish Gupta
Tag: nodejs
06-Sep-2014

Node.js

Easy app scaffolding with Yeoman

Ever wondered that the most time consuming tasks are the one you have done numerous times on numerous projects, and why the hell am i doing it again? The most basic of examples of this is Scaffolding an app, you have to do a lot of things, repetitive things to get the app structure up to speed. This is an even bigger problem with...

by Manoj Nama
Tag: nodejs
06-Jul-2014

Node.js

Defining custom errors – NodeJS

Any well written piece of code should be defensive by nature with defensive error handling understanding that things could go wrong. Things would be great if we can define our own custom error classes which we can pass or throw in order to distinguish various errors. Custom error constructors helps in: ⇒   Identifying...

by Kushal Likhi
Tag: nodejs
23-Jun-2014

Node.js

_id With Mongoose

Let us take a very common use-case: "There will be a registration page for users, where users will provide their required details along with their picture”. Details would be saved to MongoDB while the pictures would be uploaded to Cloudinary or S3 with user unique id." Suppose we have User Schema as given below: [js] /* * Schema...

by Amit Kumar
Tag: nodejs
12-Apr-2014

Node.js

Async module for node.js

In our node js application, sometimes we have to execute functions either synchronously or asynchronously. To achieve so , we have a node js module "async" that helps us to push down our functions in an array, so that we can execute them as per the need of the project. Installation Part: Run this command to install the "async" module...

by Vibhor Kukreja
Tag: nodejs
03-Apr-2014

Node.js

Validation with Mongoose

In one of our Node.js projects, we used Mongoose module to interact with MongoDB. Mongoose provides us four types of built-in validation on schema as below: 1. Required: We can mark a field as required, which must be provided. 2. Limit: If field is type of Number in Schema, then we can restrict maximum and minimum value for that...

by Amit Kumar
Tag: nodejs
19-Feb-2014

Node.js

Singleton Pattern with JavaScript

Many a times, we face a requirement where we need only one object of a class to communicate across the application. Singleton Pattern comes into role in this scenario. Singleton is one of my favorite Design Patterns. Singleton pattern restricts us to initialize more than one object. We implement Singleton by creating a class, having a...

by Amit Kumar
Tag: nodejs
14-Feb-2014