Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How to set primary key in mongoose?



How to set primary key in mongoose?..

Answer / Sah Navneet Kumar Ramsuraj

In Mongoose, you can set a primary key by defining the schema's `_id` field and setting its type to your desired data type. For example, for a user model with an auto-incrementing primary key:
const mongoose = require('mongoose');
const { Schema } = mongoose;
const UserSchema = new Schema({ _id: {type: Number, unique: true, autoIncrement: true}});

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More MongoDB Interview Questions

Which are the different languages supported by mongodb?

1 Answers  


Will there be journal replay programs in case of incomplete entries (if there is a failure in the middle of one)?

1 Answers  


Can we store pdf in mongodb?

1 Answers  


What is a namespace in mongodb?

1 Answers  


What is the role of use command?

1 Answers  


Why mongodb data files so large (in size)?

1 Answers  


Can mongodb store files?

1 Answers  


Where is the mongodb data stored?

1 Answers  


Does mongodb use sql?

1 Answers  


Now days, what makes mongodb best?

1 Answers  


What is syntax of for loop in r?

1 Answers  


What is mongodb named after?

1 Answers  


Categories