Db.Mysql Class
MySQL connection class
Constructor
Item Index
Methods
Properties
Methods
DELETE
-
table_from
-
[table_using=null]
Creates a query to delete rows.
Parameters:
Returns:
The resulting Db.Query object
fromDate
-
date
Returns a timestamp from a Date string
Parameters:
-
date
StringThe Date string that comes from the db
Returns:
The timestamp
fromDateTime
-
datetime
Returns a timestamp from a DateTime string
Parameters:
-
datetime
StringThe DateTime string that comes from the db
Returns:
The timestamp
info
-
[shardName='']
-
[modifications={}]
Retrieve connection information possibly modified for particular shard
Parameters:
Returns:
Parsed dsn string with possible modifications
INSERT
-
table_into
-
fields
Creates a query to insert a row into a table
Parameters:
Returns:
The resulting Db.Query object
rawQuery
-
query
-
parameters
Creates a raw query.
Parameters:
Returns:
The resulting Db.Query object
reallyConnect
-
callback
-
[shardName='']
-
[modifications={}]
-
[dontReconnect=false]
Create mysql.Connection and connects to the database table
Parameters:
-
callback
FunctionThe callback is fired after connection is complete. mysql.Connection is passed as argument
-
[shardName='']
String optionalThe name of the shard to connect
-
[modifications={}]
Object optionalAdditional modifications to table information. If supplied override shard modifications
-
[dontReconnect=false]
Boolean optionalPass true here to avoid automatically reconnecting when connection is lost
rollback
-
$criteria
Creates a query to rollback a previously started transaction.
Parameters:
-
$criteria
ArrayThe criteria to use, for sharding
Returns:
The resulting Db_Query object
SELECT
-
fields
-
tables
Creates a query to select fields from a table. Needs to be used with Db.Query.from().
Parameters:
Returns:
The resulting Db.Query object
timestamp
-
callback
Returns the timestamp the db server would have, based on synchronization
Parameters:
-
callback
Functionreceives (err, timestamp)
Returns:
toDate
-
input
Returns a Date string to store in the database
Returns:
in "yyyy-mm-dd hh:mm:ss" format
toDateTime
-
input
Returns a DateTime string to store in the database
Returns:
in "yyyy-mm-dd hh:mm:ss" format
uniqueId
-
table
-
field
-
callback
-
[where={}]
-
[options={}]
Generate an ID that is unique in a table
Parameters:
-
table
StringThe name of the table
-
field
StringThe name of the field to check for uniqueness. You should probably have an index starting with this field.
-
callback
FunctionWhen an acceptable unique ID is generated, this function is called with the ID as the first parameter.
-
[where={}]
Object optionalYou can indicate conditions here to limit the search for an existing value. The result is an id that is unique within a certain partition.
-
[options={}]
Object optionalOptional hash used to override default options:
-
[length=8]
Number optionalThe length of the ID to generate, after the prefix.
-
[characters='abcdefghijklmnopqrstuvwxyz']
String optionalAll the characters from which to construct the id
-
[prefix='']
String optionalThe prefix to prepend to the unique id.
-
[filter]
Function optionalA function that will take the generated string and check it. The filter function can modify the string by returning another string, or simply reject the string by returning false, in which case another string will be generated.
-
[onError]
Function | Q.Event optionalTriggered if an error occurs
-
UPDATE
-
table
Creates a query to update rows. Must be used with Db.Query.set
Parameters:
-
table
StringThe table to update
Returns:
The resulting Db.Query object
Properties
connection
mysql.Connection
The connection created with mysql.createConnection()
Default: null