Unfortunately, you cannot skip the primary key for the document, but you can override the contents of the primary key, you can define your own primary key for each document.
Try the following chart for her.
var PlayerSchema = new mongoose.Schema({ _id : { type: Number }, player_name : { type: String }, player_age : { type: Number }, player_country : { type: String },
});
I replaced your player_id with _id . Now you control the primary key of the document, and the system will not generate a key for you.
There are some plugins that can also use autoincremet for your primary key. https://github.com/chevex-archived/mongoose-auto-increment . You can also try them.
Also, about the error you get: Any document is an object and must be wrapped inside curly brackets , you cannot define two independent objects in one document. So you get this error.
source share