mirror of
https://github.com/seejohnrun/haste-server.git
synced 2024-11-01 03:21:21 +00:00
Fixed requested changes to RethinkDB handler
This commit is contained in:
parent
ba5c6b8d16
commit
cdd0cf3739
1 changed files with 16 additions and 16 deletions
|
@ -1,26 +1,26 @@
|
|||
var crypto = require('crypto');
|
||||
var rethink = require('rethinkdbdash');
|
||||
const crypto = require('crypto');
|
||||
const rethink = require('rethinkdbdash');
|
||||
|
||||
var RethinkDBStore = function (options) {
|
||||
this._options = options;
|
||||
this._options.silent = true;
|
||||
this._options.host = options.host || '127.0.0.1';
|
||||
this._options.port = options.port || 28015;
|
||||
this._options.db = options.db || 'haste';
|
||||
this._options.user = options.user || 'admin';
|
||||
this._options.password = options.password || '';
|
||||
this.client = rethink(this._options);
|
||||
var RethinkDBStore = (options) => {
|
||||
this.client = rethink({
|
||||
silent: true,
|
||||
host: options.host || '127.0.0.1',
|
||||
port: options.port || 28015,
|
||||
db: options.db || 'haste',
|
||||
user: options.user || 'admin',
|
||||
password: options.password || ''
|
||||
});
|
||||
};
|
||||
|
||||
RethinkDBStore.md5 = function (str) {
|
||||
var md5sum = crypto.createHash('md5');
|
||||
RethinkDBStore.md5 = (str) => {
|
||||
const md5sum = crypto.createHash('md5');
|
||||
md5sum.update(str);
|
||||
return md5sum.digest('hex');
|
||||
};
|
||||
|
||||
RethinkDBStore.prototype.set = function (key, data, callback) {
|
||||
RethinkDBStore.prototype.set = (key, data, callback) => {
|
||||
try {
|
||||
this.client.table('uploads').insert({ id: RethinkDBStore.md5(key), data: data }).run(function (error) {
|
||||
this.client.table('uploads').insert({ id: RethinkDBStore.md5(key), data: data }).run((error) =? {
|
||||
if (error) return callback(false);
|
||||
callback(true);
|
||||
});
|
||||
|
@ -29,7 +29,7 @@ RethinkDBStore.prototype.set = function (key, data, callback) {
|
|||
}
|
||||
};
|
||||
|
||||
RethinkDBStore.prototype.get = function (key, callback) {
|
||||
RethinkDBStore.prototype.get = (key, callback) => {
|
||||
this.client.table('uploads').get(RethinkDBStore.md5(key)).run((error, result) => {
|
||||
if (error || !result) return callback(false);
|
||||
callback(result.data);
|
||||
|
|
Loading…
Reference in a new issue