Skip to content

Instantly share code, notes, and snippets.

View abhishekr700's full-sized avatar
🏠
Working from home

Abhishek Ranjan abhishekr700

🏠
Working from home
  • Google
  • Bengaluru, India
  • 02:12 (UTC +05:30)
View GitHub Profile

Node.js use MongoDB using Mongoose module

( Each model in separate file )

mongo.js

This file holds connection to DB & also creates schema by importing them from other files.
//Import the mongoose module
const mongoose = require("mongoose");

//Import DB Models

Sequelize Querying Basics for newbies

Users = Table variable exported from sequelize

"options" object

=>"options" object is same for all find-like queries

Selective attributes =>

Users.findById(req.user.id,{
        attributes: ["id","username","name"]`