Skip to content
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

Create relationships using array of ids #243

Closed
joelcox opened this issue Sep 16, 2013 · 3 comments
Closed

Create relationships using array of ids #243

joelcox opened this issue Sep 16, 2013 · 3 comments

Comments

@joelcox
Copy link

joelcox commented Sep 16, 2013

Currently Restless requires you to make relationships by passing the related object:

{
  "title": "New post",
  "text": "Lorem ipsum",
  "comments":
  [
    {"id": 1, "name": "Jeffrey", "text": "Restless is awesome!"},
    {"id": 2, "name": "Joel", "text": "Second that"}
  ]
}

This makes sense when you're creating the related objects at the same time as the parent object, but not when you're making a relationship between existing objects. Therefore I'd propose adding the functionality to create relationships through passing an array of ids:

{
  "id": 1,
  "tag_ids":
  [
    1,
    2
  ]
}

Is this something people would be interested in?

(I'm aware it is possible to passing an array of objects, which only include the id, i.e.: {"comments": [{"id": 1}, {"id": 2}]})

@jfinkels
Copy link
Owner

So basically you are suggesting modifying the interface so that POSTing

{"comments": [1, 2]}

does the same thing as

{"comments": [{"id": 1}, {"id": 2}]}

Is that correct? This seems like a reasonable shorthand to me...

@joelcox
Copy link
Author

joelcox commented Sep 23, 2013

Correct. I was just thinking that this could be easily achieved with a preprocessor, but it's convenient for sure.

Joël

On Sep 23, 2013, at 6:14 AM, jfinkels notifications@github.com wrote:

So basically you are suggesting modifying the interface so that POSTing

{"comments": [1, 2]}
does the same thing as

{"comments": [{"id": 1}, {"id": 2}]}
Is that correct? This seems like a reasonable shorthand to me...


Reply to this email directly or view it on GitHub.

jfinkels added a commit that referenced this issue Feb 19, 2015
Before the behavior of Flask-Restless was a bit arbitrary. Now we force
it to comply with a concrete (though still changing) specification,
which can be found at http://jsonapi.org/.

This is a (severely) backwards-incompatible change, as it changes which
API endpoints are exposed and the format of requests and responses.

This fixes (or at least makes it much easier to fix or much easier to
mark as "won't fix") several issues, including but not limited to

  - #87
  - #153
  - #168
  - #193
  - #208
  - #211
  - #213
  - #243
  - #252
  - #253
  - #258
  - #261
  - #262
  - #303
  - #394
jfinkels added a commit that referenced this issue Feb 23, 2015
Previously, the behavior of Flask-Restless was a bit arbitrary. Now we
force it to comply with a concrete (though still changing)
specification, which can be found at http://jsonapi.org/.

This is a (severely) backwards-incompatible change, as it changes which
API endpoints are exposed and the format of requests and responses.

This change also moves JSON API compliance tests to a convenient
distinct test module, `tests.test_jsonapi.py`, so that compliance with
the specification can be easily verified. These tests correspond to
version 1.0rc2 of the JSON API specification, which can be found in
commit json-api/json-api@af5dfcc.

This change fixes (or at least makes it much easier to fix or much
easier to mark as "won't fix") quite a few issues, including but not
limited to

  - #87
  - #153
  - #168
  - #193
  - #208
  - #211
  - #213
  - #243
  - #252
  - #253
  - #258
  - #261
  - #262
  - #303
  - #394
jfinkels added a commit that referenced this issue Feb 24, 2015
Previously, the behavior of Flask-Restless was a bit arbitrary. Now we
force it to comply with a concrete (though still changing)
specification, which can be found at http://jsonapi.org/.

This is a (severely) backwards-incompatible change, as it changes which
API endpoints are exposed and the format of requests and responses.

This change also moves JSON API compliance tests to a convenient
distinct test module, `tests.test_jsonapi.py`, so that compliance with
the specification can be easily verified. These tests correspond to
version 1.0rc2 of the JSON API specification, which can be found in
commit json-api/json-api@af5dfcc.

This change fixes (or at least makes it much easier to fix or much
easier to mark as "won't fix") quite a few issues, including but not
limited to

  - #87
  - #153
  - #168
  - #193
  - #208
  - #211
  - #213
  - #243
  - #252
  - #253
  - #258
  - #261
  - #262
  - #303
  - #394
jfinkels added a commit that referenced this issue Mar 3, 2015
Previously, the behavior of Flask-Restless was a bit arbitrary. Now we
force it to comply with a concrete (though still changing)
specification, which can be found at http://jsonapi.org/.

This is a (severely) backwards-incompatible change, as it changes which
API endpoints are exposed and the format of requests and responses.

This change also moves JSON API compliance tests to a convenient
distinct test module, `tests.test_jsonapi.py`, so that compliance with
the specification can be easily verified. These tests correspond to
version 1.0rc2 of the JSON API specification, which can be found in
commit json-api/json-api@af5dfcc.

This change fixes (or at least makes it much easier to fix or much
easier to mark as "won't fix") quite a few issues, including but not
limited to

  - #87
  - #153
  - #168
  - #193
  - #208
  - #211
  - #213
  - #243
  - #252
  - #253
  - #258
  - #261
  - #262
  - #303
  - #394
jfinkels added a commit that referenced this issue Mar 5, 2015
Previously, the behavior of Flask-Restless was a bit arbitrary. Now we
force it to comply with a concrete (though still changing)
specification, which can be found at http://jsonapi.org/.

This is a (severely) backwards-incompatible change, as it changes which
API endpoints are exposed and the format of requests and responses.

This change also moves JSON API compliance tests to a convenient
distinct test module, `tests.test_jsonapi.py`, so that compliance with
the specification can be easily verified. These tests correspond to
version 1.0rc2 of the JSON API specification, which can be found in
commit json-api/json-api@af5dfcc.

This change fixes (or at least makes it much easier to fix or much
easier to mark as "won't fix") quite a few issues, including but not
limited to

  - #87
  - #153
  - #168
  - #193
  - #208
  - #211
  - #213
  - #243
  - #252
  - #253
  - #258
  - #261
  - #262
  - #303
  - #394
jfinkels added a commit that referenced this issue Mar 7, 2015
Previously, the behavior of Flask-Restless was a bit arbitrary. Now we
force it to comply with a concrete (though still changing)
specification, which can be found at http://jsonapi.org/.

This is a (severely) backwards-incompatible change, as it changes which
API endpoints are exposed and the format of requests and responses.

This change also moves JSON API compliance tests to a convenient
distinct test module, `tests.test_jsonapi.py`, so that compliance with
the specification can be easily verified. These tests correspond to
version 1.0rc2 of the JSON API specification, which can be found in
commit json-api/json-api@af5dfcc.

This change fixes (or at least makes it much easier to fix or much
easier to mark as "won't fix") quite a few issues, including but not
limited to

  - #87
  - #153
  - #168
  - #193
  - #208
  - #211
  - #213
  - #243
  - #252
  - #253
  - #258
  - #261
  - #262
  - #303
  - #394
jfinkels added a commit that referenced this issue Mar 8, 2015
Previously, the behavior of Flask-Restless was a bit arbitrary. Now we
force it to comply with a concrete (though still changing)
specification, which can be found at http://jsonapi.org/.

This is a (severely) backwards-incompatible change, as it changes which
API endpoints are exposed and the format of requests and responses.

This change also moves JSON API compliance tests to a convenient
distinct test module, `tests.test_jsonapi.py`, so that compliance with
the specification can be easily verified. These tests correspond to
version 1.0rc2 of the JSON API specification, which can be found in
commit json-api/json-api@af5dfcc.

This change fixes (or at least makes it much easier to fix or much
easier to mark as "won't fix") quite a few issues, including but not
limited to

  - #87
  - #153
  - #168
  - #193
  - #208
  - #211
  - #213
  - #243
  - #252
  - #253
  - #258
  - #261
  - #262
  - #303
  - #394
@jfinkels
Copy link
Owner

Flask-Restless now implements the JSON API protocol, so creating and updating relationships happen according to their specification, which is a bit different from the original implementation I had. (Theirs is better.)

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

No branches or pull requests

2 participants