db

db

db

API for database gateway functions.

Metadata

clearLog()

Clears the SQL log

Arguments

Name Type Required Default Options Description
None

createChange()

Shortcut function for creating change structs

Arguments

Name Type Required Default Options Description
action string Yes The name of the gateway function to run
schema struct Yes The relevant table schema
propertyname string No The property to update
indexname string No The index to update
bDropTable boolean No Used for table deployments

createData()

Create an object including array properties. Pass in a structure of property values; arrays should be passed as an array. The objectID can be ommitted and one will be created, passed in as an argument or passed in as a key of stProperties argument.

Arguments

Name Type Required Default Options Description
typename string Yes The name of the content type
stProperties struct Yes
dsn string Yes

createFieldStruct()

Creates a field struct from metadata

Arguments

Name Type Required Default Options Description
name string Yes
nullable boolean Yes
type string Yes
precision string No
bPrimaryKey boolean No false
default any No
index string No
savable boolean No true

deleteData()

Delete the specified objectid and corresponding data, including array properties and refObjects.

Arguments

Name Type Required Default Options Description
typename string Yes The name of the content type
dsn string Yes

deployChanges()

Processes an array of changes and returns an array of results

Arguments

Name Type Required Default Options Description
changes array Yes Array of changes in the form { action, schema, propertyname|indexname, bDropTable(deploySchema only) }. Other properties can be included but will be ignored.
dsn string Yes The database to update

deployType()

Arguments

Name Type Required Default Options Description
typename string Yes The name of the content type
bDropTable boolean Yes
dsn string Yes

diffSchema()

Compares type metadata to the actual database schema

Arguments

Name Type Required Default Options Description
typename string Yes The name of the content type
dsn string Yes

dropType()

Arguments

Name Type Required Default Options Description
typename string Yes The name of the content type
dsn string Yes

getData()

Get data for a specific objectid and return as a structure, including array properties and typename.

Arguments

Name Type Required Default Options Description
typename string Yes The name of the content type
bDepth numeric No 1 0:Everything (with full structs for all array field elements),1:Everything (only extended array field as structs),2:No array fields,3:No array or longchar fields
fields string No Overrides the default fields returned. NOTE: the bDepth field may restrict the list further.
dsn string Yes

getDBTypes()

Returns a struct mapping dbtype keys to their gateway components

Arguments

Name Type Required Default Options Description
None

getDefaultChanges()

Takes a table conflict struct and property/index name, and generates an array of default change structs for deployChanges.

Arguments

Name Type Required Default Options Description
stDiff struct Yes Conflict struct for a table
propertyname string No Specific property
indexname string No Specific index

getGateway()

Gets the gateway for the given db connection parameters

Arguments

Name Type Required Default Options Description
dsn string Yes
dbtype string No
dbowner string No

getLog()

Loads and returns the SQL log

Arguments

Name Type Required Default Options Description
asArray boolean No false

getLogChangeFlags()

Returns a list of the types that are flaged to have all SQL logged

Arguments

Name Type Required Default Options Description
None

getLogLocation()

Sets the file to which SQL is logged

Arguments

Name Type Required Default Options Description
None

getTableMetadata()

Returns the metadata for a given content type

Arguments

Name Type Required Default Options Description
typename string Yes The name of the content type

init()

Arguments

Name Type Required Default Options Description
dsn string No [runtime expression]
dbtype string No [runtime expression]
dbowner string No [runtime expression]
loglocation string No

initialiseGateway()

Creates the gateway for a set of connection parameters

Arguments

Name Type Required Default Options Description
dsn string Yes
dbtype string Yes
dbowner string Yes

initialiseTableMetadata()

Initialises and returns table metadata for a given content type

Arguments

Name Type Required Default Options Description
typename any Yes The package path or type component to process
schema struct No Use to provide a manually generated schema

isDeployed()

Returns True if the table is already deployed

Arguments

Name Type Required Default Options Description
typename string Yes The name of the content type
dsn string No [runtime expression]

mergeChanges()

Merges two arrays of changes. Yes, this is just an array merge function.

Arguments

Name Type Required Default Options Description
changesA array Yes
changesB array Yes

parseArrayFields()

Parses the data out of cfproperty tag for array properties

Arguments

Name Type Required Default Options Description
data struct Yes

parseComponentMetadata()

Parses the given component metadata structure and generates metadata that can be used by the DBGateway components.

Arguments

Name Type Required Default Options Description
md struct Yes Metadata for a component that follows the farcry convention of using tags to declare database specific information. This would typically be the result of calling getMetaData() on the component.
existing struct No [runtime expression] Metadata so far

parseProperty()

Parses the data out of cfproperty tag metadata and inserts default values for unspecified attributes

Arguments

Name Type Required Default Options Description
data struct Yes Struct out of the getMetadata struct for a property
parenttable string Yes The name of the parent table

run()

Simplifies access to gateway specific functions provided by plugins or projects. Returns false if the mixin does not exist.

Arguments

Name Type Required Default Options Description
name string Yes The name of the mixin function to run
dsn string Yes

setArrayData()

Passes update an array update to the gateway

Arguments

Name Type Required Default Options Description
typename string Yes The name of the content type
propertyname string Yes
objectid UUID Yes
aProperties array Yes
dsn string Yes

setData()

Passes update data to the gateway

Arguments

Name Type Required Default Options Description
typename string Yes The name of the content type
stProperties String Yes
dsn string Yes

setLogChangeFlags()

Sets the list of the types that are flaged to have all SQL logged

Arguments

Name Type Required Default Options Description
logChanges string Yes

setLogLocation()

Sets the file to which SQL is logged

Arguments

Name Type Required Default Options Description
logLocation string Yes