I am new to Mongo, so excuse me if this a dumb question.
I know that Mongo inserts an _id on the parent level object as a primary key, but is it normal for it to insert an _id for every field, or have I made some sort of mistake.
Also what is the __v field?
Here is how I'm forming this object:
Schema /models/Restaurant.js
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const Restaurants = new Schema({
name: String,
categories: [{
sandwiches: [{
name: String,
description: String,
img: String,
price: String
}]
}]
})
module.exports = mongoose.model('Restaurants', Restaurants);
And where I am seeding it:
seed.js
const rest = new Restaurants({
name: "taco bell",
categories: [{
sandwiches: [{
name: "breadedChickenFlatbread",
description: "A good sandwich",
img: "./sandwich.jpg",
price: "$8.99"
}]
}]
});
rest.save(() => {})
Are all the _id fields I am seeing, normal? Also, where is the __v field coming from?