0

I work on an webapp where users can create some kind of documents with a title (i. e. name/label of the document) and a content (i. e. a bunch of text).

On document creation, the document isn't saved in DB, the user has to click on save button in order to store the new document (current title + current content).

On renaming, if the document is already saved in the DB, the title is updated (but not the content). The user still has to click on save to save the content later if needed.

However, if it's a new document (i.e. not store in the DB yet), if the user try to rename it, should I:

  • Create a new entry in the DB with the title and an empty content
  • Create a new entry with title + current content
  • Update the title on client side only and wait the save of both (title + content) later

What do you think about it? How should I manage it?

1

I think you should only touch the database when the user is finished editing their document. So, when the user hits the Save button, whatever data is entered at that point should be saved.

In your example, if the user creates a new document, fills out a title and some content, renames the title, and then hits the Save button, the modified title and the new content should be the only things saved.

This eliminates unnecessary trips to the database until the explicit save command (in this case, the user pressing the save button) is initiated by the user.

  • I agree with keeping database activity to a minimum. For the OP, if you're worried about potential loss of data, perhaps consider using local storage? – Jason Cemra Dec 6 '16 at 0:55
0

If I visualize the document editor, it will have two form fields: One title and the other one is the rich text editor with a 'Save' button. So, if user hits 'Save' it should commit the Save command for both the title and the content.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.