Read-only collection

35 views
Skip to first unread message

Paul Bouwer

unread,
Jan 24, 2015, 1:05:12 PM1/24/15
to collect...@googlegroups.com
Does collection+json support read-only collections (no create or edit) with no extensions or modifications ?

According to the conversation in the following thread it seems as though this could be potentially be achieved by simply excluding the template from the json representation:

Read-only items

Is there merit in making this read-only behaviour explicit by extending the existing read-only extension ?

collection-json/extensions - Read only items

The existing read-only extension could be extended by adding a "read-only": true to the collection as follows:

{
 "collection":
  {
    "version": "1.0",
    "read-only": true,

    "links": [
      { "rel": "profile", "href": "http://api.svm-scriptcs.net/profile#version-data"}
    ],
    
    "items": [
      {
        "data" : [
          { "name": "version", "value": "0.13.0-nightly-150104" },
          { "name": "type", "value": "nightly" },
          { "name": "isLatest", "value": true },         
          { "name": "publishedDate", "value": "2015-01-04T06:02:30.536"}
        ],
        "links" : [
        ]
      },
      {
        "data" : [
          { "name": "version", "value": "0.12.0" },
          { "name": "type", "value": "stable" },
          { "name": "isLatest", "value": true },         
          { "name": "publishedDate", "value": "2014-12-24T19:47:22.007"}
        ],
        "links" : [
          { "name": "download", rel": "http://api.svm-scriptcs.net/profile#download", "render": "attachment", "href": "http://chocolatey.org/api/v2/package/ScriptCs/0.12.0" }
        ]
      }
    ]
  } 
}

For further background on the use case for this and more detail have a look at:


Thanks
Paul






mca

unread,
Jan 24, 2015, 1:29:35 PM1/24/15
to collect...@googlegroups.com
paul:

1 - the easiest way to signal "read-only" for everything is do not include a template. this means no adds, no edits.
2 - to indicate adds, but no edits, include a template and mark items with the extension: ["read-only" : true] (this can be the whole collection or just some items)
3 - to indicate no adds but allowed edits, do not include a template and include a ["rel" : "edit"] link for each item (this can be the whole collection or just some items)

i think this covers the space well, and has a minimum reliance on extensions (which are all backward compatible).

i understand the desired to *optimize* the use of read-only for human grokability, but i don't think it improves things from the machine side. in generic code you'll still be making the decision on a per item bases, but not you have *two* places to check (item-level, doc-level).

comments?


--
You received this message because you are subscribed to the Google Groups "Collection+JSON" group.
To unsubscribe from this group and stop receiving emails from it, send an email to collectionjso...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mca

unread,
Jan 24, 2015, 1:30:44 PM1/24/15
to collect...@googlegroups.com
BTW -  Paul: love the project you are working on. 

any chance you'll make the trip to API Days Sydney next month -- would be very cool to meet up.

Paul Bouwer

unread,
Jan 26, 2015, 3:24:16 AM1/26/15
to collect...@googlegroups.com
Thanks for the reply Mike. Apologies for the delay in responding - on the road overseas at the moment.

Excellent news that I don't need to add anything to cover my use case. I just wanted to make sure that being explicit wasn't necessary.

Thanks
Paul

Paul Bouwer

unread,
Jan 26, 2015, 3:24:54 AM1/26/15
to collect...@googlegroups.com
Good to hear :)

I'll follow up via email.
Reply all
Reply to author
Forward
0 new messages