Posts

Showing posts from December, 2021

What is Enhanced Object Literal in Javascript?

Enhanced object literals, also known as ES6 object literals. it is  set of new features introduced in ES2015 that make it easier to create and work with objects in JavaScript. Here are some of the key features of enhanced object literals: Concise property initialization:  You can now initialize object properties using a more concise syntax, especially when the variable names match the property names you want to assign.   For example: // ES5 code var name = 'John Doe'; var age = 30; var person = {   name: name,   age: age }; // ES6 code const name = 'John Doe'; const age = 30; const person = { name, age }; Computed property names:  You can now use expressions as property names, making it easier to create dynamic objects.   For example: // ES5 code var key = 'name'; var obj = {}; obj[key] = 'John Doe'; // ES6 code const key = 'name'; const obj = { [key]: 'John Doe' }; Method shorthand:  You can now define methods directly in object literals

Top Mongoose queries you must know.

Top Mongoose queries you must know. -To show database - show dbs. -To create database - use databasename -To show current db - db -To show collections - show collections -To show document in the collection - db.msndata.find() -To show document in the collection - db.msndata.find().pretty() -To exit - press ctrl c or type quit() -To insert single document - db.collectionname.insertOne(key:"value", active:true) -To insert many document - db.collectionname.insertMany([{key:"value", active:true}, {key:"value", active:true}]) -To show data with where condition - db.msndata.find({name:"NodeJs"}).pretty() -To show data with where condition and show only that field - db.msndata.find({name:"NodeJs"}, {name:1}).pretty() -To not show name field - db.msndata.find({name:"NodeJs"}, {name:0}).pretty() -To not show id field but name only - db.msndata.find({name:"NodeJs"}, {_id:0, name:1}).pretty() -To show only one result - db.msnda