Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Third pass at handling post meta #189

Merged
merged 10 commits into from May 24, 2014
Merged

Third pass at handling post meta #189

merged 10 commits into from May 24, 2014

Conversation

rmccue
Copy link
Member

@rmccue 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 this to the 1.0 milestone May 12, 2014
@rmccue rmccue self-assigned this May 12, 2014
@rmccue
Copy link
Member Author

rmccue commented May 12, 2014

Posted for feedback on the o2.

@rachelbaker rachelbaker merged commit 162dcdc into master May 24, 2014
rachelbaker added a commit that referenced this pull request May 24, 2014
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 01:53
kellbot pushed a commit to kellbot/WP-API that referenced this pull request Aug 1, 2014
Add ability to add, update, delete post_meta.  Fixes WP-API#68.  Closes WP-API#189 and WP-API#168.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants