Skip to content

Commit

Permalink
Changed around some things in datastore and using the data api pages,…
Browse files Browse the repository at this point in the history
… as requested by Rufus
  • Loading branch information
danieljohnlewis authored and rufuspollock committed Aug 13, 2012
1 parent ab7ded7 commit 31a7519
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 47 deletions.
48 changes: 48 additions & 0 deletions doc/datastore.rst
Expand Up @@ -94,3 +94,51 @@ How It Works (Technically)
3. (Assuming OK) CKAN hands (internally) to the database querying system which handles the
request

.. _datastoreapiref:

API Reference
-------------

datastore_create
~~~~~~~~~~~~~~~~

The datastore_create API endpoint allows a user to post JSON data to
be stored against a resource, the JSON must be in the following form::

{
resource_id: resource_id, # the data is going to be stored against.
fields: [], # a list of dictionaries of fields/columns and their extra metadata.
records: [], # a list of dictionaries of the data eg [{"dob": "2005", "some_stuff": ['a', b']}, ..]
}


datastore_search
~~~~~~~~~~~~~~~~

The datastore_search API endpoint allows a user to search data at a resource,
the JSON for searching must be in the following form::

{
resource_id: # the resource id to be searched against
filters : # dictionary of matching conditions to select e.g {'key1': 'a. 'key2': 'b'}
# this will be equivalent to "select * from table where key1 = 'a' and key2 = 'b' "
q: # full text query
limit: # limit the amount of rows to size defaults to 20
offset: # offset the amount of rows
fields: # list of fields return in that order, defaults (empty or not present) to all fields in fields order.
sort:
}

datastore_delete
~~~~~~~~~~~~~~~~

The datastore_delete API endpoint allows a user to delete from a resource,
the JSON for searching must be in the following form::

{
resource_id: resource_id # the data that is going to be deleted.
filters: # dictionary of matching conditions to delete
# e.g {'key1': 'a. 'key2': 'b'}
# this will be equivalent to "delete from table where key1 = 'a' and key2 = 'b' "
}

48 changes: 1 addition & 47 deletions doc/using-data-api.rst
Expand Up @@ -49,53 +49,7 @@ To the following endpoint:

* Dataset Model Endpoint: ``http://{YOUR-CKAN-INSTALLATION}/api/rest/dataset``

More details about creating a resource through the Data API are available on the :ref:`CKAN API page <api>`

API Reference
-------------

datastore_create
~~~~~~~~~~~~~~~~

The datastore_create API endpoint allows a user to post JSON data to
be stored against a resource, the JSON must be in the following form::

{
resource_id: resource_id, # the data is going to be stored against.
fields: [], # a list of dictionaries of fields/columns and their extra metadata.
records: [], # a list of dictionaries of the data eg [{"dob": "2005", "some_stuff": ['a', b']}, ..]
}


datastore_search
~~~~~~~~~~~~~~~~

The datastore_search API endpoint allows a user to search data at a resource,
the JSON for searching must be in the following form::

{
resource_id: # the resource id to be searched against
filters : # dictionary of matching conditions to select e.g {'key1': 'a. 'key2': 'b'}
# this will be equivalent to "select * from table where key1 = 'a' and key2 = 'b' "
q: # full text query
limit: # limit the amount of rows to size defaults to 20
offset: # offset the amount of rows
fields: # list of fields return in that order, defaults (empty or not present) to all fields in fields order.
sort:
}

datastore_delete
~~~~~~~~~~~~~~~~

The datastore_delete API endpoint allows a user to delete from a resource,
the JSON for searching must be in the following form::

{
resource_id: resource_id # the data that is going to be deleted.
filters: # dictionary of matching conditions to delete
# e.g {'key1': 'a. 'key2': 'b'}
# this will be equivalent to "delete from table where key1 = 'a' and key2 = 'b' "
}
More details about creating a resource through the Data API are available on the :ref:`CKAN API page <api>`. More information about the Datastore API can be found on the :ref:`datastore page <datastoreapiref>`.


Examples
Expand Down

0 comments on commit 31a7519

Please sign in to comment.