根据条件从 Marklogic 暂存中删除文档
Delete a document from Marklogic staging based on a condition
我们可以根据条件从 markLogic 暂存中删除文档吗?类似于 delete from data-hub-STAGING where name="John"
示例文档如下:
{
"source": "source1",
"name": "John",
"DOB": "1-01-1990",
"load_date": "2021-10-23 10:23:55"
}
{
"source": "source2",
"name": "John",
"DOB": "1-01-1990",
"load_date": "2021-10-23 10:23:55"
}
您可以使用cts.uris()
with a cts.jsonPropertyValueQuery()
to obtain the list of document URIs that have a JSON property named name
with the value "John", and then iterate over the list of URIs and call xdmp.documentDelete()
declareUpdate();
for (const uri of cts.uris("", null, cts.jsonPropertyValueQuery("name", "John"))) {
xdmp.documentDelete(uri);
}
XQuery 中的等价物:
cts:uris("", (), cts:json-property-value-query("name", "John")) ! xdmp:document-delete(.)
我们可以根据条件从 markLogic 暂存中删除文档吗?类似于 delete from data-hub-STAGING where name="John"
示例文档如下:
{
"source": "source1",
"name": "John",
"DOB": "1-01-1990",
"load_date": "2021-10-23 10:23:55"
}
{
"source": "source2",
"name": "John",
"DOB": "1-01-1990",
"load_date": "2021-10-23 10:23:55"
}
您可以使用cts.uris()
with a cts.jsonPropertyValueQuery()
to obtain the list of document URIs that have a JSON property named name
with the value "John", and then iterate over the list of URIs and call xdmp.documentDelete()
declareUpdate();
for (const uri of cts.uris("", null, cts.jsonPropertyValueQuery("name", "John"))) {
xdmp.documentDelete(uri);
}
XQuery 中的等价物:
cts:uris("", (), cts:json-property-value-query("name", "John")) ! xdmp:document-delete(.)