Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "rdb", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "index.js", | ||
@@ -10,5 +10,5 @@ "title": "rdb", | ||
"a": "0.4.3", | ||
"pg.js" : "*", | ||
"pg.js" : "3.1.0", | ||
"node-uuid" : "1.4.1", | ||
"promise" : "*" | ||
"promise" : "5.0.0" | ||
}, | ||
@@ -15,0 +15,0 @@ "repository" : { |
@@ -11,4 +11,4 @@ _rdb_ | ||
Based on promises. | ||
API is not documented yet, but see [examples][0] at git@github.com:alfateam/rdb-demo.git. | ||
API is not documented yet, but see [examples][0] at npmjs.org/package/rdb-demo. | ||
[0]:https://github.com/alfateam/rdb-demo | ||
[0]:https://npmjs.org/package/rdb-demo |
var tryGetFromDbById = require('./tryGetFromDbById'); | ||
function get() { | ||
var row = tryGetFromDbById.apply(null,arguments); | ||
if (row === null) | ||
throw("Row not found.") | ||
return row; | ||
return tryGetFromDbById.apply(null,arguments).then(onResult); | ||
function onResult(row) { | ||
if (row === null) | ||
throw new Error("Row not found.") | ||
return row; | ||
} | ||
} | ||
module.exports = get; |
@@ -1,2 +0,3 @@ | ||
var requireMock = require('a').requireMock; | ||
var a = require('a'); | ||
var requireMock = a.requireMock; | ||
var tryGetFromDbById = requireMock('./tryGetFromDbById'); | ||
@@ -9,2 +10,3 @@ | ||
function act(c) { | ||
c.mock = a.mock; | ||
c.tryGetFromDbById = tryGetFromDbById; | ||
@@ -16,10 +18,8 @@ c.sut = require('../getFromDbById'); | ||
c.strategy = strategy; | ||
c.resultPromise = {}; | ||
c.resultPromise.then = c.mock(); | ||
c.tryGetFromDbById.expect(c.table,c.id,c.strategy).return(c.resultPromise); | ||
function get() { | ||
try { | ||
c.returned = c.sut(table,id,strategy); | ||
} | ||
catch(thrownMsg) { | ||
c.thrownMsg = thrownMsg; | ||
} | ||
c.returnedPromise = c.sut(table,id,strategy); | ||
} | ||
@@ -26,0 +26,0 @@ |
@@ -5,6 +5,11 @@ var expected = {}; | ||
c.expected = expected; | ||
c.tryGetFromDbById.expect(c.table,c.id,c.strategy).return(expected); | ||
c.row = {}; | ||
c.resultPromise.then.expectAnything().whenCalled(onResult).return(c.expected); | ||
function onResult(cb) { | ||
c.returned = cb(c.row); | ||
} | ||
c.get(); | ||
} | ||
act.base = '../../new'; | ||
module.exports = act; |
var when = require('a').when; | ||
var c = {}; | ||
when('./get',c) | ||
.it('returns row').assertEqual(c.expected,c.returned); | ||
when(c) | ||
.it('returns row').assertEqual(c.row, c.returned) | ||
.it('returns promise').assertEqual(c.expected,c.returnedPromise); |
@@ -0,7 +1,20 @@ | ||
var expected = {}; | ||
function act(c) { | ||
c.tryGetFromDbById.expect(c.table,c.id,c.strategy).return(null); | ||
c.resultPromise.then.expectAnything().whenCalled(onResult); | ||
function onResult(cb) { | ||
try { | ||
cb(null); | ||
} | ||
catch (e) | ||
{ | ||
c.thrownMsg = e.message; | ||
} | ||
} | ||
c.get(); | ||
} | ||
act.base = '../../new'; | ||
module.exports = act; |
var when = require('a').when; | ||
var c = {}; | ||
when('./get',c) | ||
when(c) | ||
.it('throws not found').assertEqual('Row not found.',c.thrownMsg); |
var Promise = require('promise'); | ||
var objectToCallback = require('./objectToCallback'); | ||
var commit = commitFirstTime; | ||
var rollback = rollbackFirstTime; | ||
var oldDone = Promise.prototype.done; | ||
function commitFirstTime() { | ||
commit = require('./commit'); | ||
return commit(); | ||
} | ||
function rollbackFirstTime() { | ||
rollback = require('./rollback') | ||
return rollback(); | ||
} | ||
function newPromise(func) { | ||
@@ -18,0 +5,0 @@ if (!func) |
var updateField = require('../updateField'); | ||
var newEmitEvent = require('../../emitEvent'); | ||
var extractStrategy = require('./toDto/extractStrategy'); | ||
var newToDto = require('./toDto/newToDto'); | ||
var newDto = require('../../newObject'); | ||
@@ -69,3 +72,12 @@ function shallowDbRowToRow(table, values) { | ||
}; | ||
} | ||
} | ||
row.toJSON = function(strategy) { | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
args.push(table); | ||
strategy = extractStrategy.apply(null,args); | ||
var dto = newDto(); | ||
var toDto = newToDto(strategy, table, dto); | ||
return toDto(row).then(JSON.stringify); | ||
}; | ||
@@ -72,0 +84,0 @@ return row; |
@@ -8,3 +8,8 @@ var a = require('a'); | ||
function act(c){ | ||
c.updateField = requireMock('../updateField'); | ||
c.extractStrategy = requireMock('./toDto/extractStrategy'); | ||
c.newToDto = requireMock('./toDto/newToDto'); | ||
c.newObject = requireMock('../../newObject'); | ||
c.mock = mock; | ||
@@ -11,0 +16,0 @@ c.table = {}; |
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 2 instances in 1 package
316063
970
9801
1
+ Addedasap@1.0.0(transitive)
+ Addedbuffer-writer@1.0.1(transitive)
+ Addedgeneric-pool@2.0.4(transitive)
+ Addedpg-types@1.0.0(transitive)
+ Addedpg.js@3.1.0(transitive)
+ Addedpgpass@0.0.2(transitive)
+ Addedpromise@5.0.0(transitive)
+ Addedsplit@0.2.10(transitive)
- Removedasap@2.0.6(transitive)
- Removedbuffer-writer@1.0.0(transitive)
- Removedgeneric-pool@2.1.1(transitive)
- Removedpg-connection-string@0.1.3(transitive)
- Removedpg-types@1.6.0(transitive)
- Removedpg.js@4.1.1(transitive)
- Removedpgpass@0.0.3(transitive)
- Removedpromise@8.3.0(transitive)
- Removedsplit@0.3.3(transitive)
Updatedpg.js@3.1.0
Updatedpromise@5.0.0