When all document versions are _status: "Draft", why aren't the latest changes reflected in the main collection but only in the versions collection?
For example, when I am creating a document with a reference field to another collection, and the reference is to a document where all versions are drafts, then inside the hooks, the referenced document doesn't have the latest state, but rather the origin state (state at creation) because that is the sate stored in the main collection.
I'm trying to understand this design principle and decide if I'm using versions wrongly and should disable drafts.
Sorry if I don't understand your question correctly.
You need to set the state yourself, so you can have a collection that is not published and only is a draft.
As-is: When all your document versions are in draft, only the origin state (at creation) is stored in DB at the main collection document, all the later stages (save as draft) are stored in _versions document.
consequences: when one collection references another via the reference field, then accessing the data of the referenced collection, you get the origin state, not the latest draft state.
solution (ugly): create a function to return the latest version of the referenced collection before using the referenced collection data.
Arghh 😄 think I miss understood versions. According to the docs, there should also be a changed status if the draft is newer than the published one; I can't get that working.
Do you want the relationship to be the newest draft, not the published one?
In this context, there are no published versions. All are draft.