The persistence to the datastore is performed via HTTP methods as following:
This inserts a Greeting object. The returned object will have the "id" field set.
POST http://localhost/dn/mydomain.Greeting
{"author":null,
"content":"test insert",
"date":1239213923232}Response:
{"author":null,
"content":"test insert",
"date":1239213923232,
"id":1}
This inserts a Person object. The returned object will have the "_id" property set.
POST http://localhost/dn/mydomain.Person
{"firstName":"Joe",
"lastName":"User",
"age":15}Response:
{"firstName":"Joe",
"lastName":"User",
"age":15,
"_id":2}
This updates a Greeting object with id=1, updating the "content" field only.
PUT http://localhost/dn/mydomain.Greeting/1
{"content":"test update"}
This updates a Person object with identity of 2, updating the "age" field only.
PUT http://localhost/dn/mydomain.Person/2
{"age":23}
This gets the Extent of Greeting objects. GET http://localhost/dn/mydomain.Greeting Response:
[{"author":null,
"content":"test",
"date":1239213624216,
"id":1},
{"author":null,
"content":"test2",
"date":1239213632286,
"id":2}]
GET http://localhost/dn/mydomain.Person/2 Response:
{"firstName":"Joe",
"lastName":"User",
"age":23,
"_id":2}Note that it replies with a JSONObject that has "_id" property representing the datastore id.
This performs the JDOQL query SELECT FROM mydomain.Greeting WHERE content == 'test' GET http://localhost/dn/mydomain.Greeting?content=='test' Response:
[{"author":null,
"content":"test",
"date":1239213624216,
"id":1}]
GET http://localhost/dn/google.maps.Markers/{"class":"com.google.appengine.api.datastore.Key","id":1001,"kind":"Markers"}
Response:
{"class":"google.maps.Markers",
"key":{"class":"com.google.appengine.api.datastore.Key",
"id":1001,
"kind":"Markers"
},
"markers":[
{"class":"google.maps.Marker",
"html":"Paris",
"key":{"class":"com.google.appengine.api.datastore.Key",
"id":1,
"kind":"Marker",
"parent":{"class":"com.google.appengine.api.datastore.Key",
"id":1001,
"kind":"Markers"
}
},
"lat":48.862222,
"lng":2.351111
}
]
} |