I have an app in the works for use internally as a project/task tracker in the company that I’m working for. Playing around with MongoDB atm. I have the following pseudo-schema in mind:
task
_id
name
project
initial_notes
versions
number
versions
version_1
worker
status
date(if submitted)
review_notes(if rejected)
reply_on(if accepted/rejected)
(version_n)(if any)
The problem that I’m having is with versioning the task. I’ve read a number of possible ways but I’m falling short of understanding them all the way through. I read something that I liked here and really like the way mongoid does it’s versioning
Thinking of it better I’d rather have it something like this
task
_id
versions
number_of_versions: 3
current_version
version_no: 3
worker: bob
status: accepted
old_versions
version
version_no: 2
worker: bob
I would like to show the most recent version only when displaying a collection of tasks and I would like to show all versions of a particular task when entering the detailed information page for that particular task. Would this structure work? If yes, what would be some queries needed to run in order to achieve what I need?
Thank you in advance for your time reading this and maybe answering it.
status: rejected
version
version_no: 1
worker: smith
status: rejected
Yes, why not. That scheme would work. Also, have you considered something like this:
Possible version insertion query:
Note, that retrieving the last version from the versions array in this case is done by the program, not by Mongo.