I’m working on a project to create a web application similar to Excel, where users can edit cells in a spreadsheet. I need help designing the database schema using MongoDB to support the following features:
-
Editable Cells: Users should be able to edit the content of individual cells.
-
Merge/Unmerge Cells: Users should be able to merge multiple cells into one and later unmerge them.
-
Persistent State: The state of the cells (including merged cells) should be saved so that users see the same configuration when they return to the page|
How can I design a MongoDB schema to handle these requirements effectively? Any advice on best practices or potential pitfalls would be greatly appreciated.
I was thinking about a collection for the spreadsheets and another for the cells, but I’m not sure how to represent merged cells. Here’s a rough idea:
{
"spreadsheets": [
{
"_id": "spreadsheet_id",
"name": "Spreadsheet 1",
"cells": [
{
"cell_id": "A1",
"content": "Data",
"merged_with": ["A2", "A3"]
},
{
"cell_id": "A2",
"content": "",
"merged_with": ["A1", "A3"]
},
{
"cell_id": "A3",
"content": "",
"merged_with": ["A1", "A2"]
}
]
}
]
}