Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Remove orphaned amps at wipe #404

Closed
grtjn opened this issue Mar 12, 2015 · 1 comment
Closed

Remove orphaned amps at wipe #404

grtjn opened this issue Mar 12, 2015 · 1 comment
Assignees
Milestone

Comments

@grtjn
Copy link
Contributor

grtjn commented Mar 12, 2015

Related to #282. Ken shared code to remove orphaned amps, worth a look if that can be integrated into wipe:

let $script :=
'xquery version "1.0-ml";

declare namespace sec="http://marklogic.com/xdmp/security";

declare function local:db-exists($id) as xs:boolean
{
  if($id = 0) then fn:true()
  else
  try{
    xdmp:database-name($id)[0],fn:true()
  }
  catch($ex){
    fn:false()
  }
};

let $dead-amps := /sec:amp[fn:not(local:db-exists(./sec:database))]
return
(
for $dead-amp in $dead-amps
return
xdmp:document-delete($dead-amp)
,
xdmp:log(fn:count($dead-amps)||" dead amps removed")
)
'
return
xdmp:eval($script,(),<options
xmlns="xdmp:eval"><database>{xdmp:database("Security")}</database></options>)
grtjn added a commit to grtjn/roxy that referenced this issue Mar 24, 2015
@grtjn grtjn added this to the 1.7.2 milestone Mar 24, 2015
@grtjn grtjn self-assigned this Mar 24, 2015
dmcassel added a commit that referenced this issue Mar 24, 2015
Fixed #404: integrated Ken's code for removing orphaned amps into wipe
@grtjn
Copy link
Contributor Author

grtjn commented Mar 24, 2015

Fixed in dev

@grtjn grtjn closed this as completed Mar 24, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant