V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
ryanking8215
V2EX  ›  程序员

jsonapi 的问题,请教大家

  •  
  •   ryanking8215 ·
    ryanking8215 · Nov 5, 2014 · 2819 views
    This topic created in 4195 days ago, the information mentioned may be changed or developed.
    http://jsonapi.org

    1.通篇没有讲如何create relationship的。
    一种方法是认为relationship也是resource,拿post和comment举例,post也是comment的links
    ```
    POST /comments

    {
    content: ”xxxx",
    links: {
    posts: "1"
    }
    }
    ```

    还有一种就是create relationship.
    ```
    POST /posts/1/comments

    {
    comments: {
    content: "xxx"
    }
    }
    ```

    还有就是分2步,先创建comment,然后再updating posts/1的relationship,这样api比较啰嗦。

    你们会选哪种?
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   886 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:57 · PVG 02:57 · LAX 11:57 · JFK 14:57
    ♥ Do have faith in what you're doing.