Skip to content

Associations #41

Answered by mergesort
natebird asked this question in Q&A
Nov 26, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Apologies for the long reply time @natebird, I've been dealing with some health issues and family matters so open source has taken a bit of a back seat over the last month or two. I'll probably be a bit slow to reply for a bit, but I wanted to provide you an answer that may be helpful, with some code and a real world scenario from one of my apps.


Imagine you have two models, a Tag and a RichLink (basically a link but with additional metadata).

  1. A link can contain zero or many tags.
  2. A tag can exist independent of any links, so you can have a tag that has zero associated links.

The models for Tag and RichLink look like this.

public struct RichLink: Codable, Equatable, Identifiable {
    p…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@natebird
Comment options

Answer selected by natebird
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants