Comparing version
@@ -16,2 +16,5 @@ /** | ||
this.config = config; | ||
this.config.host = config.host || 'localhost'; | ||
this.config.port = config.port || 3306; | ||
this.connected = false; | ||
@@ -130,4 +133,3 @@ this.lastError = null; | ||
var config = this.config; | ||
//this.client = mysql.createConnectionSync(config.host, config.user, config.password, config.database); | ||
this.client = mysql.createConnectionSync(config.host, config.user, config.password); | ||
this.client = mysql.createConnectionSync(config.host, config.user, config.password, config.database, config.port); | ||
if (config.database) { | ||
@@ -134,0 +136,0 @@ this.client.query('USE '+config.database); |
@@ -285,3 +285,3 @@ /** | ||
}); | ||
primaryKey = row.column_name; | ||
if (row) primaryKey = row.column_name; | ||
if (client.strict && !primaryKey) { | ||
@@ -288,0 +288,0 @@ console.error("STRICT WARNING: Primary Key not defined in database for `"+tableName+"`."); |
@@ -19,5 +19,5 @@ /** | ||
Mapper.prototype.connect = function(connParams, options) { | ||
Mapper.prototype.connect = function(config, options) { | ||
options = options || {}; | ||
var client = new Client(connParams, options); | ||
var client = new Client(config, options); | ||
client.connect(); | ||
@@ -24,0 +24,0 @@ this.Base = new Base(client); |
{ | ||
"name": "mapper", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Lightweight, blazing fast ORM on top of mysql-libmysqlclient.", | ||
@@ -5,0 +5,0 @@ "tags" : ["orm", "mysql", "mysql-libmysqlclient"], |
@@ -14,5 +14,2 @@ # Mapper | ||
Speed and simplicity. | ||
See [mapper-obtvse example project](https://github.com/mgutz/mapper-obtvse.git) | ||
@@ -27,2 +24,7 @@ | ||
NOTE: There are currently two mapper implementations. The legacy | ||
as used in `test/integration/legacy.js` which will be obseleted. | ||
The current implementeation is used in `test/integration/integrationTest.js`. | ||
## Quickstart | ||
@@ -29,0 +31,0 @@ |
@@ -16,3 +16,3 @@ var async = require("async") | ||
if (iteration % 2 === 0) { | ||
client.query("insert into users(userName, firstName, lastName) values('libmysql', 'is', 'fast')", function(err, result) { | ||
client.query("insert into Users(userName, firstName, lastName) values('libmysql', 'is', 'fast')", function(err, result) { | ||
//if (iteration === 2) console.log(result); | ||
@@ -22,3 +22,3 @@ cb(err); | ||
} else { | ||
client.query("select userName, firstName, lastName from users limit 50", function(err, result) { | ||
client.query("select userName, firstName, lastName from Users limit 50", function(err, result) { | ||
result.fetchAll(function(err, rows) { | ||
@@ -25,0 +25,0 @@ //if (iteration === 3) console.log(rows); |
@@ -8,3 +8,3 @@ var async = require("async") | ||
var UserDao = Mapper.Base.extend({ | ||
tableName: "users" | ||
tableName: "Users" | ||
}); | ||
@@ -11,0 +11,0 @@ |
@@ -7,3 +7,3 @@ var async = require("async") | ||
var UserDao = Mapper.map("users"); | ||
var UserDao = Mapper.map("Users"); | ||
@@ -10,0 +10,0 @@ |
@@ -18,9 +18,9 @@ var async = require("async") | ||
if (iteration % 2 === 0) { | ||
client.query("insert into users(userName, firstName, lastName) values('mysql', 'is', 'slow');", function(err, result) { | ||
if (iteration === 2) console.log(result); | ||
client.query("insert into Users(userName, firstName, lastName) values('mysql', 'is', 'slow');", function(err, result) { | ||
//if (iteration === 2) console.log(result); | ||
cb(err); | ||
}); | ||
} else { | ||
client.query("select userName, firstName, lastName from users limit 50;", function(err, rows, fields) { | ||
if (iteration === 3) console.log(rows); | ||
client.query("select userName, firstName, lastName from Users limit 50;", function(err, rows, fields) { | ||
//if (iteration === 3) console.log(rows); | ||
cb(err); | ||
@@ -27,0 +27,0 @@ }); |
@@ -8,3 +8,3 @@ var prompt = require("./prompt") | ||
bench: | ||
"CREATE TABLE users( \ | ||
"CREATE TABLE Users( \ | ||
id int not null auto_increment primary key, \ | ||
@@ -18,3 +18,3 @@ userName varchar(255), \ | ||
posts: | ||
"CREATE TABLE posts (\ | ||
"CREATE TABLE Posts (\ | ||
id integer NOT NULL,\ | ||
@@ -30,3 +30,3 @@ title character varying(255) NOT NULL,\ | ||
tags: | ||
"CREATE TABLE tags (\ | ||
"CREATE TABLE Tags (\ | ||
id integer NOT NULL,\ | ||
@@ -36,3 +36,3 @@ name varchar(64))", | ||
postsTags: | ||
"CREATE TABLE postsTags (\ | ||
"CREATE TABLE PostsTags (\ | ||
id integer NOT NULL,\ | ||
@@ -43,3 +43,3 @@ postId int not null,\ | ||
moreDetails: | ||
"CREATE TABLE postMoreDetails (\ | ||
"CREATE TABLE PostMoreDetails (\ | ||
id integer NOT NULL,\ | ||
@@ -50,3 +50,3 @@ postId int not null,\ | ||
comments: | ||
"CREATE TABLE comments (\ | ||
"CREATE TABLE Comments (\ | ||
id integer NOT NULL,\ | ||
@@ -60,3 +60,3 @@ postId integer NOT NULL,\ | ||
"CREATE INDEX comments_post_id \ | ||
ON comments(postId)" | ||
ON Comments(postId)" | ||
}; | ||
@@ -63,0 +63,0 @@ |
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
127
1.6%123785
-1.28%34
-5.56%3820
-1.39%