From abe545397b69b12399b0d23530c3ee2b18604a59 Mon Sep 17 00:00:00 2001 From: Sundog Date: Fri, 20 Oct 2023 09:37:57 -0400 Subject: [PATCH] more model refinement --- MODELS.md | 44 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/MODELS.md b/MODELS.md index 8be6a47..399a6d2 100644 --- a/MODELS.md +++ b/MODELS.md @@ -287,23 +287,14 @@ struct Article { A Comment represents a textual comment that a Person wants to attach contextually to an Artist, an Album, a Track, or a Playlist. ``` rust -enum CommentTargetType { - Label, - Artist, - Album, - Track, - Playlist, - Article, - Comment, -} -struct CommentTargetId { - label_id: Option, - artist_id: Option, - album_id: Option, - track_id: Option, - playlist_id: Option, - article_id: Option, - comment_id: Option, +enum CommentTarget { + Label(LabelId), + Artist(ArtistId), + Album(AlbumId), + Track(TrackId), + Playlist(PlaylistId), + Article(ArticleId), + Comment(CommentId), } struct CommentId { id: String, @@ -311,8 +302,7 @@ struct CommentId { struct Comment { id: CommentId, body: String, - target_type: CommentTargetType, - target_id: CommentTargetId, + target: CommentTarget, created_by: PersonId, created_at: chrono::DateTime, modified_by: Option, @@ -436,10 +426,10 @@ A Purchase represents one or more Tracks or Albums that a Person purchases from ``` rust enum PurchaseItemType { - Album, - Track, - Collection, - OtherProduct, + Album(AlbumId), + Track(TrackId), + Collection(CollectionId), + OtherProduct(OtherProductId), } struct PurchaseItemId { id: String, @@ -449,10 +439,7 @@ struct SkuId { } struct Sku { id: SkuId, - album_id: Option, - track_id: Option, - collection_id: Option, - other_product_id: Option, + item: PurchaseItemType, variant: Option, description: Option, price: Option, @@ -460,8 +447,7 @@ struct Sku { } struct PurchaseItem { id: PurchaseItemId, - type: PurchaseItemType, - sku: Option, + sku: SkuId, quantity: usize, } enum PurchaseState {