Skip to content

[feature] add mkdir -p like function to xmldb XQuery module #4238

Open
@line-o

Description

@line-o

I've seen one-off implementations - and built one of my own - to solve a common problem:

Create an collection where missing parent collections will be created.

On the linux command line this is possible by setting the -p flag on mkdir.

mkdir -p `/this/is/a/deeply/nested/directory`

nodeJS for example mimics this behaviour by setting the recursive option on the builtin fs.mkdir method.

There is no such facility present in eXistdb to my knowledge. That is why I propose to add that by either

  1. a new function xmldb:create-collection-recursive accepting one parameter:
  • collectionUri as xs:string
  1. or add a signature to xmldb:create-collection accepting two parameters:
  • collectionUri as xs:string
  • options as xs:map
  1. create a new builtin XQuery module that will handle this and all other collection operations. This module would then deprecate
    currently available functions xmldb:create-collection, xmldb:collection-available and the like. While this is definitely a controversial proposal it also has the potential to rethink our current approach while maintaining backwards compatibility.

The fact that xmldb:create-collection already has a two parameter signature does rule out option 2 unless we choose to also
introduce a breaking change. The current xmldb:create-collection#2 would have to be changed to
xmldb:create-collection($collectionUri as xs:string) as xs:string removing the parent collection parameter that is currently expected.

I personally favor having the collection URIs to be in one parameter but certainly am open to discuss the motivation behind the current implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementnew features, suggestions, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions