I have database name.
I need to get db resource.
How? One option I see is to execute Config.Databases:List
query and iterate over results till I find required name. After that open db by path and get the resource.
If you have only name of the database, you should before get a directory, because SYS.Database works only with directory path.
set dbName="TEST"
if ##Class(Config.Databases).Exists(dbName,.dbconfobj) {
Set dbObj=##class(SYS.Database).%OpenId(dbconfobj.Directory)
Set resourceName = dbObj.ResourceName
}
Database directory also you could get in this way
if ##Class(Config.Databases).Get("TEST1",.props) {
write $get(props("Directory"))
}
Or directory for default database for current namespace
set directory=$zu(12,"")