The persistence to the datastore is performed via HTTP methods as following:
| Method | Operation | URL format | Return | Arguments |
|---|---|---|---|---|
| POST | Insert object | /{full-class-name} | The JSON Object is returned. | The JSON Object is passed in the HTTP Content. |
| PUT | Update object | /{full-class-name}/{primary key} | The JSON Object is returned. | The JSON Object is passed in the HTTP Content. The primary-key is specified in the URL if the PK is application-identity single field or if it is datastore-identity |
| DELETE | Delete object | /{full-class-name}/{primary key} | The primary key fields are passed in the HTTP Content (JSONObject) if the PK uses multiple PK fields, otherwise in the URL. | |
| DELETE | Delete all objects of type | /{full-class-name} | ||
| GET | Fetch all objects of type | /{full-class-name} | JSON Array of JSON objects | |
| GET | Fetch a single object | /{full-class-name}/{primary key} | A JSON object | The primary key fields are passed in the HTTP Content (JSONObject) if the PK uses multiple PK fields, otherwise in the URL |
| GET | Query objects via a filter. Returns a JSON Array of objects | /{full-class-name}?{filter} | JSON Array of JSON objects | Filter component of a JDOQL query |
| GET | Query objects via JDOQL. Returns a JSON Array of objects | /jdoql?{JDOQL-single-string-query} /query?{JDOQL-single-string-query} |
JSON Array of JSON objects | JDOQL single string query |
| GET | Query objects via JPQL. Returns a JSON Array of objects | /jpql?{JPQL-single-string-query} | JSON Array of JSON objects | JPQL single string query |
| HEAD | Validates if an object exists | /{full-class-name}/{primary key} | The primary key fields are passed in the HTTP Content (JSONObject) if the PK uses multiple PK fields, otherwise in the URL |
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
}
]
}