
admin.databaseAddField( config as element(configuration), database-id as (Number|String), fields as element(db.field)[] ) as element(configuration)
This function adds the field specification to the specified database in the configuration.
http://marklogic.com/xdmp/privileges/admin/database
http://marklogic.com/xdmp/privileges/admin/database/{id}
http://marklogic.com/xdmp/privileges/admin/database/index
http://marklogic.com/xdmp/privileges/admin/database/index/{id}
  
  const admin = require('/MarkLogic/admin.xqy');
  const config = admin.getConfiguration()
  const dbid = xdmp.database("myDatabase")
  const fieldspec = admin.databaseField("myField", fn.true() )
  admin.databaseAddField(config, dbid, fieldspec)
   //returns the new configuration element -- use admin.saveConfiguration
   //to save the changes to the configuration or pass the configuration
   //to other Admin API functions to make other changes.  
  
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.