HTTP/REST + JSON =
                      JSON Web Databases                                             Database interacti...
Schemas

                                                                   • DB defined schema - ActiveRecord
           ...
JSONPath                                                                                   JSONPath querying in requests

...
Live Data Notifications with REST
                                                                             Channels


...
Upcoming SlideShare
Loading in...5
×

HTTP/REST JSON = Database interaction for the web

2,193

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,193
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
54
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "HTTP/REST JSON = Database interaction for the web"

  1. 1. HTTP/REST + JSON = JSON Web Databases Database interaction for the web Applied JSON: HTTP REST, Ajax databases and beyond Kris Zyp, SitePen Copyright SitePen, Inc. 2008. All Rights Reserved Overview Interoperability Basics •Interoperability Basics • HTTP REST • GET - query and get by id •Tools/Frameworks • PUT - update an object •Beyond simple CRUD • POST - create an object • DELETE - delete an object Copyright SitePen, Inc. 2008. All Rights Reserved Copyright SitePen, Inc. 2008. All Rights Reserved Tools/Frameworks Standard Conventions • Client Side • Objects/records accessible by /table/id • Persevere • /Product/12 • Jester • GET, PUT, and DELETE this resource • Dojo • Sub object URLs determined by object identity • Server Side properties • ActiveResource • GET /Product/ • CouchDB [{“id”:”11”, “name”:”Dérailleur”}, {“id”:”12”, “name”:”Handle Bar”}] • Persevere • GrassyKnoll • ... Copyright SitePen, Inc. 2008. All Rights Reserved Copyright SitePen, Inc. 2008. All Rights Reserved 1
  2. 2. Schemas • DB defined schema - ActiveRecord • Schema free - CouchDB The post-ORM realm Enter URL or footnote here; delete if not required. Long text and/or URLs will wrap automatically for you. Copyright SitePen, Inc. 2008. All Rights Reserved Copyright SitePen, Inc. 2008. All Rights Reserved Evolutionary Schema: JSON Schema based Persevere evolutionary schema Add Start without a constraints as schema application evolves Copyright SitePen, Inc. 2008. All Rights Reserved Copyright SitePen, Inc. 2008. All Rights Reserved Querying • Web-safe portability important • SQL extremely hard to make secure and too JSON Schema driven UI complicated in the browser • JSONPath Start with • JavaScript-style syntax schema • Language agnostic • Easy to secure http://goessner.net/articles/JsonPath/ Copyright SitePen, Inc. 2008. All Rights Reserved Copyright SitePen, Inc. 2008. All Rights Reserved 2
  3. 3. JSONPath JSONPath querying in requests XPath like query language for JSON JSONPath + REST URLs = Web querying Filters - [?expr] /Table/ - All the objects in a table Properties/paths (like JS) - .prop /Table/[?@.price < 10] – all items with a price under $10 Recursive descent - ..prop /Table/..name – A list of the name property values Slice operator – [3:10:2] /Table/.length – A count of the items in the table Union operator - [3,4,5] http://goessner.net/articles/JsonPath/ Copyright SitePen, Inc. 2008. All Rights Reserved Copyright SitePen, Inc. 2008. All Rights Reserved JSONQuery Referencing • Cyclic • Multiple references • Cross-message references Lenient Syntax - ?price<10 Sorting - [/price, rating] • Cross-site references Mapping - [=firstName+' '+lastName] Wildcarding [?description='*fun*'] Recursive object filter - ..[?name='Bar'] Example URL: /Table/[?price<10] [={name:name, rating: rating}] [rating] http://www.sitepen.com/blog/2008/06/17/json-referencing-in-dojo/ http://www.sitepen.com/blog/2008/07/16/jsonquery-data-querying-beyond-jsonpath/ Copyright SitePen, Inc. 2008. All Rights Reserved Copyright SitePen, Inc. 2008. All Rights Reserved Security with web accessible data Server side JavaScript + web storage storage "schema":{ “name”:”Friend”, “properties”:{ • Typical databases behind the application “firstName”:{“type”:”string”}, “age”:{“type”:”integer”}, • Web DBs are directly accessible } • User authorization becomes integrated with data "staticCreateMethod":function(arg1){ var friend = new Friend; • Allows separation of application and security concerns friend.age = 0; }, "prototype":{ “myMethod”:function(){ return this.firstName + ‘ ‘ + this.lastName; } } "extends":{"$ref":"../Person"} } http://sitepen.com/labs/persevere.php Copyright SitePen, Inc. 2008. All Rights Reserved Copyright SitePen, Inc. 2008. All Rights Reserved 3
  4. 4. Live Data Notifications with REST Channels Transactions http://cometdaily.com/2008/05/13/http-channels-2/ Copyright SitePen, Inc. 2008. All Rights Reserved Copyright SitePen, Inc. 2008. All Rights Reserved REST/Ajax JSON Databases Persevere • Standards based interoperable web database • JSONQuery/JSONPath interaction • JSON Referencing • More direct, cleaner model for creating web • Comet Live Data Notifications applications • JSON Schema with evolutionary constraints • Leverage the web's REST model • JSON-RPC • Caching, proxying, etc. • Built-in Security • Standards based REST interface http://sitepen.com/labs/persevere.php Copyright SitePen, Inc. 2008. All Rights Reserved Copyright SitePen, Inc. 2008. All Rights Reserved REST/ Ajax databases Develop for the future Copyright SitePen, Inc. 2008. All Rights Reserved Copyright SitePen, Inc. 2008. All Rights Reserved 4

×