MarkLogic and CRUD operations: for Better Performance.

Reading Time: 5 minutes
MarkLogic and CURD operations: for Better Performance.
(Note: The Above Image is just for reference purposes, we didn’t claim its ownership it is a courtesy of https://developer.marklogic.com/)

Introduction

We have been working a lot on MarkLogic Streams and it’s great to see how many people are using them. As part of this work, we’ve also been able to release some new capabilities that allow you to do CRUD operations using the HTTP protocol. We think this will make it easier for people who want to build applications that require more flexibility than what’s possible with CRUD alone. so we will see how MarkLogic and CRUD operations work together in a way for Better Performance.

What is CRUD?

CRUD is an acronym for creating, updating, reading, and deleting operations. You can use it to interact with an API:

  • Create a new record by issuing POST requests to the /api/create endpoint.
  • Update an existing record by calling PUT on /api/:id or PATCH on any other resource (see below). For example:
    “php curl -X PUT http://localhost:8080/users/1 HTTP/1.1 Host: localhost Connection: keep-alive Content-Type: application/json; charset=utf-8 Date: Wed, 16 Feb 2019 15:25 GMT { “name”: “Sebastian”, “email”: “[email protected]” }“`

MarkLogic will allow you to execute CRUD commands via the HTTP protocol

MarkLogic will allow you to execute CRUD commands via the HTTP protocol. The HTTP protocol is a stateless protocol, which means that each request must include all the information required to process it. In other words, if one request doesn’t include all the required information then subsequent requests will fail as well because none of them have been able to retrieve their data from an incomplete state.

This can be particularly problematic when executing CRUD operations on large datasets since it may take several seconds or even minutes before they are complete (depending on how many times you make changes and what type of database engine your application uses). If a single change requires loading multiple objects into memory then this would create a situation where one part of your application could run but another could not because they were waiting for each other’s responses – meaning there’d be no way for either part-way through processing any changes made by either side! now we will see how MarkLogic and CRUD operations work together in a way for Better Performance.

MarkLogic REST API

Allows you to create and update documents by using HTTP requests. You can also read the content of documents from the server.

A Create & update operation :

PUT is the most popular method of creating and updating documents in RDM. It can be used to create new documents, or update existing ones. PUT requests are idempotent, which means that they do not cause any side effects on their target system if executed multiple times with the same parameters (e.g., a single PUT request with different values for key-value pairs). In addition, since all operations are performed by clients through HTTP requests over TCP/IP connections between client and server applications respectively running on machines within the same network segment (or even across continents), there is no need for any kind of authentication when performing these requests.

hence we can say that PUT requests are stateless since they don’t require any authentication credentials from either party involved in sending each other’s data back and forth over HTTP protocol alone as long as both parties have valid internet connectivity at all times when communicating with each other using web protocols such as SSL/TLS security protocols etcetera!

Section: PUT

MarkLogic puts a document into MarkLogic by uploading it to the server. This can be done with either the command-line interface (CLI) or through a REST API call.

To upload a file using the CLI:

  • Enter: put /path/to/file.xlsx –filename=myfile.xlsx * The output will look like this:

Section: POST

POST is the formal name for an HTTP method. It stands for “POST,” which means that you’re sending data in this request. This type of request can be used to create or update resources on your server, as well as retrieve and delete them.

A read operation :

GET is used to retrieve data. It’s used in all situations where you want to get information from a server, database, or web server.
For example:

  • Getting the weather forecast for your city (HTTP)
  • Getting a list of all the songs on your iPod (HTTPS)

Section: GET

The GET method of a request is used to retrieve information from a resource. The URI for a resource is the address that you use to access it (the URL). A response can be sent in any format, but if there is no response body, it will be an empty string.

A delete Operation:

  • Delete a document using the HTTP DELETE method. For example, if you want to remove a document from your database and don’t have access to MarkLogic’s REST API, you can use this command:
  • DELETE /api/document_id_to_delete/?delete=true&deltainfo=true&version=6.0

Section: DELETE

DELETE is the command that you need to use when you want to delete a document. As with other REST requests, delete requires an id parameter and returns a 204 status code if successful.

Retrieve HTTP headers :

The HEAD method is used to retrieve the HTTP headers. It can be used to check if a resource exists and also its size.

If you want to get information about the status code of your request, then you should use the GET method. If you want to know more about what happened during the processing of this request then use the HEAD method instead of “GET” because it will return only some information like:

  • Content-Length (Number) – This value specifies how long content should be returned when using the HEAD method for retrieving data from the server.
  • Last-Modified (String) – This value represents the time when last modified or created by the server and contains a date/time stamp indicating when the file was last modified or created on the server respectively.

Section: HEAD

You can use the HTTP headers to check if a resource exists and the HTTP status code.

  • The Accept header is used to specify the formats of resources that are acceptable in the response. It can be used with most protocols except for TCP/IP, which does not use this field.
  • The Content-Type header specifies how data should be formatted for transmission over an HTTP connection between client and server application programs running on different platforms using different protocols; it also provides information about how files will be interpreted by the receiving computer system (e.g., whether they are compressed).

This is interesting.

So, what does this mean for us?

It means that MarkLogic can now be used as a REST API. This means that we can now use MarkLogic in our applications, instead of directly connecting to it. It also means that we don’t need to worry about all the different ways of calling functions, like PUT and POST (which are similar but not identical) or DELETE, HEAD, and GET. All we need is an endpoint where users call their CRUD operations on their data: 1) Create new records 2) Update existing records 3) Delete old ones 4) Search through them so MarkLogic and CRUD operations work together in a way for Better Performance.

Conclusion

You can see the value of MarkLogic for your organization. It will save you time, energy, and money. With the right amount of training and support, your users will be able to access their data in an intuitive way that is easy to use. thus we can say that MarkLogic and CRUD operations work together in a way for Better Performance.

For More Info you can refer to our Blogs :
1) Basic Concepts of CRUD operation.
2) MarkLogic Official Guide.