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

Third pass at handling post meta #189

Merged
merged 10 commits into from May 24, 2014

Conversation

Projects
None yet
3 participants
@rmccue
Member

rmccue commented May 12, 2014

This pass at post meta builds off the previous (#168, #188), but changes the format around.

When retrieving meta:

{
    "ID": 13,
    "post_meta": [
        {
            "ID": 33,
            "key": "my_meta_key",
            "value": "My value!"
        }
    ]
}

To update, you just change the value and send it back:

{
    "ID": 13,
    "post_meta": [
        {
            "ID": 33,
            "key": "my_meta_key",
            "value": "My new value!"
        }
    ]
}

To add a new value, you add an object to the array without an ID:

{
    "ID": 13,
    "post_meta": [
        {
            "key": "another_key",
            "value": "Another value"
        }
    ]
}

To delete a value, you set the key and value to null:

{
    "ID": 13,
    "post_meta": [
        {
            "ID": 33,
            "key": null,
            "value": null
        }
    ]
}

Side-effect: you can rename meta keys by changing the key when updating, as it's no longer used as the primary key.

Disadvantages: This cannot be read from the meta cache. I don't see this being a huge issue, as it's only exposed on context=edit.

Fixes #68.

@rmccue rmccue added the Enhancement label May 12, 2014

@rmccue rmccue added this to the 1.0 milestone May 12, 2014

@rmccue rmccue self-assigned this May 12, 2014

@rmccue

This comment has been minimized.

Show comment
Hide comment
@rmccue

rmccue May 12, 2014

Member

Posted for feedback on the o2.

Member

rmccue commented May 12, 2014

Posted for feedback on the o2.

@rachelbaker rachelbaker merged commit 162dcdc into master May 24, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details

rachelbaker added a commit that referenced this pull request May 24, 2014

Merge pull request #207 from WP-API/post-meta-handling-v4
Add ability to add, update, delete post_meta.  Fixes #68.  Closes #189 and #168.

@rmccue rmccue deleted the post-meta-handling-v3 branch May 25, 2014

kellbot pushed a commit to kellbot/WP-API that referenced this pull request Aug 1, 2014

Merge pull request #207 from WP-API/post-meta-handling-v4
Add ability to add, update, delete post_meta.  Fixes #68.  Closes #189 and #168.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment