@@ -37,7 +37,9 @@ v8::Handle<v8::Value> node_db_mysql::Mysql::New(const v8::Arguments& args) {
37
37
}
38
38
39
39
if (args.Length () > 0 ) {
40
- v8::Handle<v8::Value> set = binding->set (args);
40
+ ARG_CHECK_OBJECT (0 , options);
41
+
42
+ v8::Handle<v8::Value> set = binding->set (args[0 ]->ToObject ());
41
43
if (!set.IsEmpty ()) {
42
44
return scope.Close (set);
43
45
}
@@ -48,11 +50,12 @@ v8::Handle<v8::Value> node_db_mysql::Mysql::New(const v8::Arguments& args) {
48
50
return scope.Close (args.This ());
49
51
}
50
52
51
- v8::Handle<v8::Value> node_db_mysql::Mysql::set (const v8::Arguments& args) {
52
- v8::Handle<v8::Value> result = node_db::Binding::set (args);
53
-
54
- v8::Local<v8::Object> options = args[0 ]->ToObject ();
55
-
53
+ v8::Handle<v8::Value> node_db_mysql::Mysql::set (const v8::Local<v8::Object> options) {
54
+ ARG_CHECK_OBJECT_ATTR_OPTIONAL_STRING (options, hostname);
55
+ ARG_CHECK_OBJECT_ATTR_OPTIONAL_STRING (options, user);
56
+ ARG_CHECK_OBJECT_ATTR_OPTIONAL_STRING (options, password);
57
+ ARG_CHECK_OBJECT_ATTR_OPTIONAL_STRING (options, database);
58
+ ARG_CHECK_OBJECT_ATTR_OPTIONAL_UINT32 (options, port);
56
59
ARG_CHECK_OBJECT_ATTR_OPTIONAL_STRING (options, charset);
57
60
ARG_CHECK_OBJECT_ATTR_OPTIONAL_BOOL (options, compress);
58
61
ARG_CHECK_OBJECT_ATTR_OPTIONAL_STRING (options, initCommand);
@@ -65,6 +68,31 @@ v8::Handle<v8::Value> node_db_mysql::Mysql::set(const v8::Arguments& args) {
65
68
66
69
node_db_mysql::Connection* connection = static_cast <node_db_mysql::Connection*>(this ->connection );
67
70
71
+ v8::String::Utf8Value hostname (options->Get (hostname_key)->ToString ());
72
+ v8::String::Utf8Value user (options->Get (user_key)->ToString ());
73
+ v8::String::Utf8Value password (options->Get (password_key)->ToString ());
74
+ v8::String::Utf8Value database (options->Get (database_key)->ToString ());
75
+
76
+ if (options->Has (hostname_key)) {
77
+ connection->setHostname (*hostname);
78
+ }
79
+
80
+ if (options->Has (user_key)) {
81
+ connection->setUser (*user);
82
+ }
83
+
84
+ if (options->Has (password_key)) {
85
+ connection->setPassword (*password);
86
+ }
87
+
88
+ if (options->Has (database_key)) {
89
+ connection->setDatabase (*database);
90
+ }
91
+
92
+ if (options->Has (port_key)) {
93
+ connection->setPort (options->Get (port_key)->ToInt32 ()->Value ());
94
+ }
95
+
68
96
if (options->Has (charset_key)) {
69
97
v8::String::Utf8Value charset (options->Get (charset_key)->ToString ());
70
98
connection->setCharset (*charset);
@@ -104,7 +132,7 @@ v8::Handle<v8::Value> node_db_mysql::Mysql::set(const v8::Arguments& args) {
104
132
connection->setWriteTimeout (options->Get (writeTimeout_key)->ToInt32 ()->Value ());
105
133
}
106
134
107
- return result ;
135
+ return v8::Handle<v8::Value>() ;
108
136
}
109
137
110
138
v8::Persistent<v8::Object> node_db_mysql::Mysql::createQuery () const {
0 commit comments