CRUD
Yep that's Create, Read, Update, and Delete. We use the term Insert instead of Create but that doesn't keep us from saying CRUD for fun. MarkLogic provides a simple API for CRUD.
To insert a document, send a PUT
request to the /documents
endpoint with the document URI
as a parameter. The format
parameter specifies the documents format. For example, to store a JSON document with URI /afternoon-drink.json
:
where you get myhost:port
and your username
and password
from your database administrator.
If you haven't seen the curl
tool before, it's a popular command line http client,
that is ideal for playing with REST apis. If you don't have a copy, look here.
curl
supports specifying your credentials on the command line with a --user username:password
flag. Alternatively, you can store these in your .curlrc
file. This and additional details on curl can
be found in its manual page.
If you'd rather have MarkLogic automatically generate a unique URI for you, you can send the original document via a POST, along with an extension parameter to indicate the format.
(The MarkLogic response includes a Location
header that contains the URI
of the new document.)
To update the existing document, send another PUT
request:
And to delete the document, send a DELETE
request:
The REST API provides additional functionality related to CRUD, including
- Updating pieces of documents
- Transforming documents during retrieval (for example, to HTML on the way out)
- Transforming documents during during insertion (for example, to XML on the way in)
- Managing document metadata (collections, permissions, properties, quality)
- And much more!
Basic Concepts
Search and Query APIs
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.