简体   繁体   中英

How to perform CRUD operations in Marklogic Server?

I want to do CRUD operations on xml docs stored in Marklogic Server. Can anybody tell me please how can I perform CRUD operations in Marklogic Server ?

How are you connecting to the MarkLogic database? This may make a big difference in how you go about doing CRUD.

If you are pushing data in using an HTTP service you can use an existing REST endpoint such as the Corona project or make your own using XQuery.

If you are using Java or .Net you can connect through the XCC library, which have functions for CRUD without having to write XQuery.

In pure XQuery the following commands may be useful to read up on in the MarkLogic XQuery function documentation on the MarkLogic web site:

  • xdmp:document-insert()
    • this will do the Create and Update of CRUD
  • fn:doc-available()
    • if you want to test to see if a document exists. Some people doing CRUD want this in order to make Create and Update different . Other's don't care.
  • xdmp:document-delete()
    • the Delete in CRUD
  • fn:doc()
    • the Read in CRUD

Once the document is stored, you use functions like xdmp:node-replace() , xdmp:node-insert-child() etc. to manipulate the document node-by-node. Alternatively, you can change a document by saving a new version to the same URI via xdmp:document-insert() , or delete a document via xdmp:document-delete() .

Note that the transactional semantics in MarkLogic are truly functional, so the document never changes during execution of a transaction. You need to complete the transaction and get the document from the database to see the changes.

另请参阅http://community.marklogic.com/try/corona/index以获取更高级别的API。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM