I am currently developing an Android App focused on baseball, and I have decided to use MongoDB to store my data. The format in which I would like my JSON data stored in the database is as follows:
{"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f59098949c99b5919a98994b8fb3939597">[email protected]</a>":{
"coachName": "Smith",
players:[
player1:{
"throws_":"n\/a",
"position":"position not set",
"number":"1",
"playerNum":"H8E83NxRo6",
"bats":"n\/a",
"team_name":"Team",
"name":"Name"
},
player2:{
"throws_":"n\/a",
"position":"position not set",
"number":"1",
"playerNum":"H8E83NxRo6",
"bats":"n\/a",
"team_name":"Team",
"name":"Name"
}
]
}
If there are any syntax errors, please forgive me, but that's the structure I aim for in my JSON. In this layout, the person's email serves as the Mongo page ID, and "players" represents an array of players under a specific coach. I have several questions regarding implementing this:
How can I properly configure the Mongoose schema to match this structure?
Once the app sends the JSON data, how can I parse it to effectively store the information?
If multiple players are added simultaneously, how can I add them to the existing array of players?
All these aspects pertain to backend/server-side operations. My android application is functioning well, I just require assistance with storing the data as specified using JavaScript.