Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
theowenyoung opened this issue Nov 12, 2021 · 0 comments
Open

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

theowenyoung opened this issue Nov 12, 2021 · 0 comments

Comments

@theowenyoung
Copy link

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?

@theowenyoung theowenyoung changed the title Should includes arrays be de-duplicated for same id,type? Should included arrays be de-duplicated for same id,type? Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant