Child pages
  • Database Manager

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Rev: 1377846239207
Wiki Markup
{div:style=display:none}
DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
		THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR.\\		\\		Enter additional information related to this 'class' inside the \{div} macro with 'id=description'{div}
{div:id=description}{div}\\ 

{table:id=|class=servoy sReturnTypes}{tr:style=height: 30px;}{th}Return Types{th}{tr}{tr}{td}{span:class=sWordList}[JSFoundSet]{span}{span:class=sWordList}[JSRecord]{span}{td}{tr}{table}\\ 

{table:id=|class=servoy sSummary}{colgroup}{column:width=80px|padding=0px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Property Summary{th}{tr}{table}\\ 

{table:id=|class=servoy sSummary}{colgroup}{column:width=80px|padding=0px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Method Summary{th}{tr}{tbody}{tr}{td}[String]{td}{td}[#getDataSource]\(serverName, tableName)
Returns the datasource corresponding to the given server/table.{td}{tr}{tbody}{tbody}{tr}{td}[String]{td}{td}[#getDataSourceServerName]\(dataSource)
Returns the server name from the datasource, or null if not a database datasource.{td}{tr}{tbody}{tbody}{tr}{td}[String]{td}{td}[#getDataSourceTableName]\(dataSource)
Returns the table name from the datasource, or null if the specified argument is not a database datasource.{td}{tr}{tbody}{tbody}{tr}{td}[JSFoundSet]{td}{td}[#getFoundSet]\(dataSource)
Returns a foundset object for a specified datasource or server and tablename.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#hasRecords]\(foundset)
Returns true if the (related)foundset exists and has records.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#hasRecords]\(record, relationString)
Returns true if the (related)foundset exists and has records.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#saveData]\()
Saves all outstanding (unsaved) data and exits the current record.{td}{tr}{tbody}{table}\\ 

{table:id=property|class=servoy sDetail}{colgroup}{column:width=100%|padding=0px}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Property Details{th}{tr}{table}\\ 

{table:id=function|class=servoy sDetail}{colgroup}{column:width=100%|padding=0px}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=getDataSource-String_String}{tr:id=name}{td}h6.getDataSource{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[String]{span}{span:style=font-weight: bold;}getDataSource{span}{span}\(serverName, tableName){span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} serverName -- The name of the table's server.
\{[String]} tableName -- The table's name.
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[String] -- The datasource of the given table/server.{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var datasource = databaseManager.getDataSource('example_data', 'categories');
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getDataSourceServerName-String}{tr:id=name}{td}h6.getDataSourceServerName{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[String]{span}{span:style=font-weight: bold;}getDataSourceServerName{span}{span}\(dataSource){span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} dataSource -- The datasource string to get the server name from.
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[String] -- The servername of the datasource.{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var servername = databaseManager.getDataSourceServerName(datasource);
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getDataSourceTableName-String}{tr:id=name}{td}h6.getDataSourceTableName{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[String]{span}{span:style=font-weight: bold;}getDataSourceTableName{span}{span}\(dataSource){span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} dataSource -- The datasource string to get the tablename from.
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[String] -- The tablename of the datasource.{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var theTableName = databaseManager.getDataSourceTableName(datasource);
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getFoundSet-String}{tr:id=name}{td}h6.getFoundSet{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[JSFoundSet]{span}{span:style=font-weight: bold;}getFoundSet{span}{span}\(dataSource){span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} dataSource -- The datasource to get a JSFoundset for.
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[JSFoundSet] -- A new JSFoundset for that datasource.{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
// type the foundset returned from the call with JSDoc, fill in the right server/tablename
/** @type {JSFoundset<db:/servername/tablename>} */
var fs = databaseManager.getFoundSet(controller.getDataSource())
var ridx = fs.newRecord()
var record = fs.getRecord(ridx)
record.emp_name = 'John'
databaseManager.saveData()
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=hasRecords-JSFoundSet}{tr:id=name}{td}h6.hasRecords{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}hasRecords{span}{span}\(foundset){span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[JSFoundSet]} foundset -- A JSFoundset to test.
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean] -- true if the foundset/relation has records.{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
if (elements.customer_id.hasRecords(orders_to_orderitems))
{
	//do work on relatedFoundSet
}
//if (elements.customer_id.hasRecords(foundset.getSelectedRecord(),'orders_to_orderitems.orderitems_to_products'))
//{
//	//do work on deeper relatedFoundSet
//}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=hasRecords-JSRecord_String}{tr:id=name}{td}h6.hasRecords{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}hasRecords{span}{span}\(record, relationString){span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[JSRecord]} record -- A JSRecord to test.
\{[String]} relationString -- The relation name.
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean] -- true if the foundset/relation has records.{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
if (elements.customer_id.hasRecords(orders_to_orderitems))
{
	//do work on relatedFoundSet
}
//if (elements.customer_id.hasRecords(foundset.getSelectedRecord(),'orders_to_orderitems.orderitems_to_products'))
//{
//	//do work on deeper relatedFoundSet
//}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=saveData}{tr:id=name}{td}h6.saveData{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}saveData{span}{span}\(){span}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean] -- true if the save was done without an error.{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
databaseManager.saveData();
//databaseManager.saveData(foundset.getRecord(1));//save specific record
//databaseManager.saveData(foundset);//save all records from foundset

// when creating many records in a loop do a batch save on an interval as every 10 records (to save on memory and roundtrips)
// for (var recordIndex = 1; recordIndex <= 5000; recordIndex++) 
// {
//		foundset.newRecord();
//		someColumn = recordIndex;
//		anotherColumn = "Index is: " + recordIndex;
//		if (recordIndex % 10 == 0) databaseManager.saveData();
// }
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}