I am working on a web application (the back-end is written in Node.js with a mongo-db), where the user can make, document and describe decisions. I am representing this in a tree structure as follows
{
tree: {
root: Node,
nodes: [{ // keeping a reference to all nodes of the tree
index: Number,
node: Node
}],
lastIndex: Number
}
}
Where Node is
{
parent: Node,
children: [Node],
data: {
d1: String,
d2: [String],
d3: Number,
d4: Boolean
// more data fields as above, probably not more than 10-20 fields per node
},
index: Number // this node's index in the tree's node map
}
On the web application (i.e. in the browser), the user can perform the following actions:
- Create a new tree
- Add a node to a tree
- Edit the data of a node
- Delete a complete subtree
- Change the order of the children of a node
- Load a complete tree
The main action will be, to add new nodes and to describe them (fill the data fields). This can be done via mouse input mostly, so if the user is clicking quickly, he can create up to 5-10 nodes per second.
I want to send these modifications in real-time to the server and store them in the database (mongo-db). (Also I'm thinking about showing feedback on the page, that the current state is saved on the server, but I think this will come at a later point).
So it comes down to these requirements:
- Most of the time I will be dealing with create- and update-actions on the nodes table (possibly many creates/updates per user per second).
- There won't be much data sent from server to client (except when a new tree is loaded).
So, in my case, is it better to use REST calls or a websocket connection?
All help is really appreciated!