Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.

Commit

Permalink
mongodb query sample added, unnecessary files removed
Browse files Browse the repository at this point in the history
  • Loading branch information
erhangundogan committed Jan 10, 2013
1 parent 1be6112 commit 99c0807
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 249 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Project is under development.
### How to Install

```bash
npm install sql2mongodb
npm install -d sql2mongodb
```

### How to use
Expand Down
12 changes: 12 additions & 0 deletions mongodb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

// SELECT TOP 1 row, PriceID, Country FROM prices
// WHERE Country='EG' AND row<10000
// ORDER BY row DESC

db.prices.find(
{Country:'EG',
row:{$lt:10000}},
{row:1, PriceID:1, Country:1})
.sort({row:-1})
.limit(1)
.pretty()
7 changes: 4 additions & 3 deletions sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ sqlConnection.prototype.testServer = function(callback) {
};
sqlConnection.prototype.getTable = function(table, mongodbServer, socket, callback) {
var self = this,
rows = [], columns = [], queryString = [],
rows = [], columns = [],
schema = {}, ItemSchema = {}, ItemModel = {}, request = {},
lastRowID = 0,
count = 10000,
Expand All @@ -112,6 +112,7 @@ sqlConnection.prototype.getTable = function(table, mongodbServer, socket, callba
if (start >= tableCount) {
return callback(null, "all rows retrieved");
}
var queryString = [];

queryString.push("DECLARE @ColumnName NVARCHAR(60)");
queryString.push("SET @ColumnName = (SELECT TOP 1 name FROM sys.columns WHERE object_id = OBJECT_ID('dbo.");
Expand All @@ -137,7 +138,7 @@ sqlConnection.prototype.getTable = function(table, mongodbServer, socket, callba
request = new Request(query, function(err) {
if (err) {
console.log(err);
callback(err, null);
return callback(err, null);
}
});

Expand All @@ -154,7 +155,7 @@ sqlConnection.prototype.getTable = function(table, mongodbServer, socket, callba
});

request.on("row", function(row) {
socket.emit("done", ++readRows + " kayıt MSSQL'den alındı");
socket.emit("append", ++readRows + " kayıt MSSQL'den alındı");
var newRow = {};

for (var colNumber in row) {
Expand Down
25 changes: 0 additions & 25 deletions transfer.js

This file was deleted.

220 changes: 0 additions & 220 deletions utils.js

This file was deleted.

0 comments on commit 99c0807

Please sign in to comment.