Hi! First post and relatively new to mongo db. Also I have hit my google limit and might switch back to sql database if I can’t figure this out soon
Question: How do I create a document of the schema below? Specifically how do I create the profile with only the array data field, disccollection, filled out. I have this schema implemented in the demo, however I have to create the profile first. Then after the profile is created, then I was able to add data to the disccollection field.
To restate the question: How do I create a document in mongo db atlas that is only an array of objects.
I am using nodejs and mongoose to connect with mongo atlas.
Background info: The demo and github for the app I am working is listed below
const ProfileSchema = new mongoose.Schema({
user: {
type: mongoose.Schema.Types.ObjectId,
ref: "user",
},
favoritedisc: {
type: String,
},
disccollection: [
{
discname: {
type: String,
required: true,
},
discmanufacturer: {
type: String,
}, }, ],});
Working demo (it is using a free dyno on mongo atlas so give it a second to load if the dyno is asleep ). If you register an account, you will have to create a profile, before being able to create your disc golf bag. If you click on Create Disc Bag it just goes to empty page. That is not related to my mongo db issue.
https://enigmatic-beyond-47734.herokuapp.com/
Thanks, Dan