Java, Node.js

MONGOOSE Tips and Tricks for Uncommon Cases

Mongoose is an object modelling package for Node that essentially works like an ORM for many popular languages much like Hibernate is for JAVA. Below are some of the mongoose special scenario(s) I stepped upon while working on the project. It took me some time to figure it out. Hopefully below details would prove helpful to you thereby...

by Rachit Jain
Tag: Mongoose
27-Jun-2017

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: Mongoose
13-Feb-2015

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: Mongoose
12-Apr-2014

Node.js

Getting started with Mongoose !!

Mongoose is a Node.js package that gives you an interface to play with mongo database. Mongoose has all sets of methods that help you to connect and access data stored in database. It translates data from database in javaScript object which you can provide to your application. We will move step by step to know how it works. 1....

by ajay.mishra
Tag: Mongoose
07-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: Mongoose
19-Feb-2014