admin:database-get-id

admin:database-get-id(
   $config as element(configuration),
   $database-name as xs:string
) as xs:unsignedLong

Summary

This function returns the ID for the specified database from the configuration. The difference between this function and xdmp:database() is that the ID from this function can come from a database that has not yet been saved (that is, from a database that has been created in the same query with the Admin library but has not yet been saved to the cluster configuration files). This ID enables you to completely configure a newly created database without the need to first save the configuration.

Parameters
config A configuration specification, typically as returned from one of the Admin module functions.
database-name The name of the database.

Example

  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
		  at "/MarkLogic/admin.xqy";

  let $config := admin:get-configuration()
  let $config := admin:database-create($config, "myNewDatabase", 
                  xdmp:database("Security"), xdmp:database("Schemas"))
  let $databaseID := admin:database-get-id($config, "myNewDatabase")
  let $fieldspec := admin:database-field("myField", fn:true() )
  let $config := admin:database-add-field($config, $databaseID, $fieldspec)

  return 
      admin:database-attach-forest($config, $databaseID,
          xdmp:forest("newForest") ) 

  (: Attaches "newForest" and adds the field, "myField" to the newly created 
     database, "myNewDatabase" :)
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy