Skip to content

Should included arrays be de-duplicated for same id,type? #84

Description

@theowenyoung

Hi, for now ,the following example will generate 4 chapters with id =1 :

    let book = vec![
        Book {
            id: "1".into(),
            title: "The Fellowship of the Ring".into(),
            first_chapter: Chapter {
                id: "1".into(),
                title: "A Long-expected Party".into(),
                ordering: 1,
            },
            chapters: vec![Chapter {
                id: "1".into(),
                title: "A Long-expected Party".into(),
                ordering: 1,
            }],
        },
        Book {
            id: "2".into(),
            title: "The Fellowship of the Ring".into(),
            first_chapter: Chapter {
                id: "1".into(),
                title: "A Long-expected Party".into(),
                ordering: 1,
            },
            chapters: vec![Chapter {
                id: "1".into(),
                title: "A Long-expected Party".into(),
                ordering: 1,
            }],
        },
    ];

    let doc = vec_to_jsonapi_document(book);
    dbg!(&doc);
    assert!(doc.is_valid());
 included: Some(
            [
                Resource {
                    _type: "chapters",
                    id: "1",
                    attributes: {
                        "ordering": Number(
                            1,
                        ),
                        "title": String(
                            "A Long-expected Party",
                        ),
                    },
                    relationships: None,
                    links: None,
                    meta: None,
                },
                Resource {
                    _type: "chapters",
                    id: "1",
                    attributes: {
                        "ordering": Number(
                            1,
                        ),
                        "title": String(
                            "A Long-expected Party",
                        ),
                    },
                    relationships: None,
                    links: None,
                    meta: None,
                },
                Resource {
                    _type: "chapters",
                    id: "1",
                    attributes: {
                        "ordering": Number(
                            1,
                        ),
                        "title": String(
                            "A Long-expected Party",
                        ),
                    },
                    relationships: None,
                    links: None,
                    meta: None,
                },
                Resource {
                    _type: "chapters",
                    id: "1",
                    attributes: {
                        "title": String(
                            "A Long-expected Party",
                        ),
                        "ordering": Number(
                            1,
                        ),
                    },
                    relationships: None,
                    links: None,
                    meta: None,
                },
            ],

Should these chapters be deduplicated?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions