MySQL NDB Cluster API Developer Guide
Converter classes convert between JavaScript types and MySQL types. If the user supplies a JavaScript converter, it used to read and write to the database.
Converters have several purposes, including the following:
The ndb back end also uses converters to support
SET and
ENUM columns. (The mysql back end
does not use these.)
A Converter class has the interface defined
here:
function Converter() {}:
Converter.prototype = {
"toDB" : function(obj) { },
"fromDB" : function(val) { }
};
The Converter must
implement the following two functions:
toDB(:
Convert an application object obj)obj
into a form that can be stored in the database.
fromDB(:
Convert a value val)val read from the
database into application object format.
Each function returns the result of the conversion.
Converter invocations are chained in the following ways:
When writing to the database, first the registered
FieldConverter, if any, is invoked.
Later, any registered TypeConverter is
invoked.
When reading from the database, first the registered
TypeConverter, if any, is invoked. Later,
any registered FieldConverter is invoked.