简体   繁体   English

如何在Marklogic Server中执行CRUD操作?

[英]How to perform CRUD operations in Marklogic Server?

I want to do CRUD operations on xml docs stored in Marklogic Server. 我想对存储在Marklogic Server中的xml文档进行CRUD操作。 Can anybody tell me please how can I perform CRUD operations in Marklogic Server ? 有人可以告诉我如何在Marklogic Server中执行CRUD操作吗?

How are you connecting to the MarkLogic database? 您如何连接到MarkLogic数据库? This may make a big difference in how you go about doing CRUD. 这可能会对您进行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. 如果要使用HTTP服务推送数据,则可以使用现有的REST端点(例如Corona项目),也可以使用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. 如果使用Java或.Net,则可以通过XCC库进行连接,该库具有CRUD功能,而无需编写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: 在纯XQuery中,以下命令对于在MarkLogic网站上的MarkLogic XQuery功能文档中进行阅读很有用:

  • xdmp:document-insert()
    • this will do the Create and Update of CRUD 这将执行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 . 某些进行CRUD的人希望这样做,以便使Create和Update与众不同。 Other's don't care. 别人不在乎。
  • xdmp:document-delete()
    • the Delete in CRUD 在CRUD中删除
  • fn:doc()
    • the Read in CRUD 读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. 一旦存储了文档,就可以使用xdmp:node-replace()xdmp:node-insert-child()等函数xdmp:node-replace()操作文档。 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() . 另外,您可以通过将新版本通过xdmp:document-insert()保存到相同的URI来xdmp:document-insert() ,或者通过xdmp:document-delete()

Note that the transactional semantics in MarkLogic are truly functional, so the document never changes during execution of a transaction. 请注意,MarkLogic中的事务语义确实具有功能,因此文档在执行事务期间永不更改。 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。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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