Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change some components to levelup from noDB
Way too much code duplication in the added lib/* files. Also need to move sessions away from noDB.
- Loading branch information
1 parent
548406d
commit aa3c73e
Showing
12 changed files
with
311 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var levelup = require('levelup'); | ||
var userdb = levelup('./users'); | ||
var feeddb = levelup('./feeds'); | ||
var hitdb = levelup('./hits'); | ||
var tagdb = levelup('./tags'); | ||
var fs = require('fs'); | ||
var oldusers = JSON.parse(fs.readFileSync('./users.json').toString()); | ||
var oldfeeds = JSON.parse(fs.readFileSync('./feedTargets.json').toString()); | ||
var oldhits = JSON.parse(fs.readFileSync('./feedHits.json').toString()); | ||
var oldtags = JSON.parse(fs.readFileSync('./tags.json').toString()); | ||
for (user in oldusers) { | ||
oldusers[user].email = user; | ||
userdb.put(user, JSON.stringify(oldusers[user])); | ||
} | ||
for (var i = 0 ; i < oldfeeds.length ; i++ ) { | ||
var feed = oldfeeds[i]; | ||
feeddb.put(feed.yes, JSON.stringify(feed)); | ||
} | ||
for (var i = 0 ; i < oldhits.length ; i++ ) { | ||
var hit = oldhits[i]; | ||
hitdb.put(hit.url, JSON.stringify(hit)); | ||
}; | ||
for (var i = 0 ; i < oldtags.length ; i++ ) { | ||
var tag = oldtags[i]; | ||
tagdb.put(tag.elements.join('/'), JSON.stringify(tag)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var levelup = require('levelup'); | ||
var db = levelup('./data/feeds'); | ||
module.exports = { | ||
get: function(key, cb) { | ||
db.get(name, function(err, value) { | ||
cb(err, JSON.parse(value)); | ||
}); | ||
} | ||
, store: function(feed, cb) { | ||
db.put(feed.yes, JSON.stringify(feed), cb); | ||
} | ||
, del: function(key, cb) { | ||
db.del(key, cb); | ||
} | ||
, keys: function(cb) { | ||
keys = []; | ||
db.createKeyStream() | ||
.on('data', function(data) { | ||
keys.push(data) | ||
}).on('end', function() { | ||
cb(null, keys); | ||
}) | ||
} | ||
, all: function(cb) { | ||
var res = {}; | ||
db.createReadStream() | ||
.on('data', function(data) { | ||
res[data.key] = JSON.parse(data.value) | ||
}).on('end', function() { | ||
cb(null, res); | ||
}) | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var levelup = require('levelup'); | ||
var db = levelup('./data/hits'); | ||
module.exports = { | ||
get: function(key, cb) { | ||
db.get(name, function(err, value) { | ||
cb(err, JSON.parse(value)); | ||
}); | ||
} | ||
, store: function(hit, cb) { | ||
db.put(hit.url, JSON.stringify(hit), cb); | ||
} | ||
, del: function(key, cb) { | ||
db.del(key, cb); | ||
} | ||
, keys: function(cb) { | ||
keys = []; | ||
db.createKeyStream() | ||
.on('data', function(data) { | ||
keys.push(data) | ||
}).on('end', function() { | ||
cb(null, keys); | ||
}) | ||
} | ||
, all: function(cb) { | ||
var res = {}; | ||
db.createReadStream() | ||
.on('data', function(data) { | ||
res[data.key] = JSON.parse(data.value) | ||
}).on('end', function() { | ||
cb(null, res); | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var levelup = require('levelup'); | ||
var db = levelup('./data/tags'); | ||
module.exports = { | ||
get: function(key, cb) { | ||
db.get(name, function(err, value) { | ||
cb(err, JSON.parse(value)); | ||
}); | ||
} | ||
, store: function(tag, cb) { | ||
db.put(tag.elements.join('/'), JSON.stringify(tag), cb); | ||
} | ||
, del: function(tag, cb) { | ||
db.del(tag.elements.join('/'), cb); | ||
} | ||
, keys: function(cb) { | ||
keys = []; | ||
db.createKeyStream() | ||
.on('data', function(data) { | ||
keys.push(data) | ||
}).on('end', function() { | ||
cb(null, keys); | ||
}) | ||
} | ||
, all: function(cb) { | ||
var res = {}; | ||
db.createReadStream() | ||
.on('data', function(data) { | ||
res[data.key] = JSON.parse(data.value) | ||
}).on('end', function() { | ||
cb(null, res); | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var levelup = require('levelup'); | ||
var db = levelup('./data/users'); | ||
user = { | ||
get: function(name, cb) { | ||
db.get(name, function(err, value) { | ||
cb(err, JSON.parse(value)); | ||
}); | ||
} | ||
, store: function(user, cb) { | ||
db.put(user.email, JSON.stringify(user), cb); | ||
} | ||
, del: function(key, cb) { | ||
db.del(key, cb); | ||
} | ||
, keys: function(cb) { | ||
keys = []; | ||
db.createKeyStream() | ||
.on('data', function(data) { | ||
keys.push(data) | ||
}).on('end', function() { | ||
cb(null, keys); | ||
}) | ||
} | ||
, all: function(cb) { | ||
var res = {}; | ||
db.createReadStream() | ||
.on('data', function(data) { | ||
res[data.key] = JSON.parse(data.value) | ||
}).on('end', function() { | ||
cb(null, res); | ||
}) | ||
} | ||
}; | ||
module.exports = user; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.