Comparing version 0.3.0 to 0.3.1
@@ -66,2 +66,47 @@ !function(){ | ||
} | ||
, gte: function(value) { | ||
return function(){ | ||
return { | ||
operator: '>=' | ||
, value: value | ||
} | ||
} | ||
} | ||
, lt: function(value) { | ||
return function(){ | ||
return { | ||
operator: '<' | ||
, value: value | ||
} | ||
} | ||
} | ||
, lte: function(value) { | ||
return function(){ | ||
return { | ||
operator: '<=' | ||
, value: value | ||
} | ||
} | ||
} | ||
, not: function(value) { | ||
return function(){ | ||
return { | ||
operator: 'not' | ||
, value: value | ||
} | ||
} | ||
} | ||
, is: function(value) { | ||
return function(){ | ||
return { | ||
operator: 'is' | ||
, value: value | ||
} | ||
} | ||
} | ||
}); | ||
@@ -68,0 +113,0 @@ |
{ | ||
"name" : "ee-orm" | ||
, "description" : "An easy to use ORM for node.js. Supports advanced eager loading, complex queries, joins, transactions, complex database clusters & connection pooling." | ||
, "version" : "0.3.0" | ||
, "version" : "0.3.1" | ||
, "homepage" : "https://github.com/eventEmitter/ee-orm" | ||
@@ -6,0 +6,0 @@ , "author" : "Michael van der Weg <michael@eventemitter.com> (http://eventemitter.com/)" |
@@ -30,5 +30,3 @@ | ||
}).save(log);*/ | ||
db.image.setMappingAccessorName('venue_image', 'venue'); | ||
db.image().describeMethods(); | ||
db.event({id:1}).getImage(['*']).getVenue(['*']).find(cb); | ||
db.event({canceled: ORM.notNull()}).find(cb); | ||
@@ -35,0 +33,0 @@ /* |
@@ -12,3 +12,15 @@ | ||
var expect = function(val, cb){ | ||
return function(err, result){ | ||
try { | ||
assert.equal(JSON.stringify(result), val); | ||
} catch (err) { | ||
return cb(err); | ||
} | ||
cb(); | ||
} | ||
}; | ||
['POSTGRES'].forEach(function(db){ | ||
@@ -288,9 +300,3 @@ var config | ||
, eventLocale: [new db.eventLocale({description: 'some text', language: db.language({id:1})})] | ||
}).save(function(err, event){ | ||
if (err) done(err); | ||
else { | ||
assert.equal(JSON.stringify(event), '{"eventLocale":[{"language":{"id":1,"code":"en"},"description":"some text"}],"id":2,"venue":{"id":1,"name":"Dachstock Reitschule"},"title":"Mapping Test","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":null}'); | ||
done(); | ||
} | ||
}); | ||
}).save(expect('{"eventLocale":[{"language":{"id":1,"code":"en"},"description":"some text"}],"id":2,"venue":{"id":1,"name":"Dachstock Reitschule"},"title":"Mapping Test","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":null}', done)); | ||
}); | ||
@@ -305,9 +311,4 @@ | ||
, venue: db.venue({id:1}) | ||
}).save(function(err, event){ | ||
if (err) done(err); | ||
else { | ||
assert.equal(JSON.stringify(event), '{"image":[{"id":6,"url":"http://imgur.com/gallery/laxsJHr"}],"id":3,"venue":{"id":1,"name":"Dachstock Reitschule"},"title":"Mapping Test","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":null}'); | ||
done(); | ||
} | ||
}); | ||
, canceled: true | ||
}).save(expect('{"image":[{"id":6,"url":"http://imgur.com/gallery/laxsJHr"}],"id":3,"venue":{"id":1,"name":"Dachstock Reitschule"},"title":"Mapping Test","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":true}', done)); | ||
}); | ||
@@ -378,7 +379,16 @@ }); | ||
db.event({id:1}).getImage(['*']).getVenue(['*']).find(function(err, events){ | ||
db.event({id:1}).getImage(['*']).getVenue(['*']).find(expect('[{"image":[{"id":1,"url":"http://gfycat.com/ScentedPresentKingfisher.gif","venue":[{"id":2,"name":"Dachstock Reitschule"}]}],"id":1}]', done)); | ||
}); | ||
}); | ||
describe('Updating existing Data', function(){ | ||
it('for a simple entity using the loaded model should work', function(done){ | ||
db.event({id:1}).findOne(function(err, event){ | ||
if (err) done(err); | ||
else { | ||
assert.equal(JSON.stringify(events), '[{"image":[{"id":1,"url":"http://gfycat.com/ScentedPresentKingfisher.gif","venue":[{"id":2,"name":"Dachstock Reitschule"}]}],"id":1}]'); | ||
done(); | ||
event.title = 'Changed title'; | ||
event.save(expect('{"id":1,"title":"Changed title","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":null}', done)); | ||
} | ||
@@ -388,3 +398,45 @@ }); | ||
}); | ||
describe('[Filtering]', function(){ | ||
it('Filter by a value', function(done){ | ||
db.event({id: 1}).findOne(expect('{"id":1,"title":"Changed title","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":null}', done)); | ||
}); | ||
it('Filter using null', function(done){ | ||
db.event({canceled: null}).find(expect('[{"id":2,"title":"Mapping Test","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":null},{"id":1,"title":"Changed title","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":null}]', done)); | ||
}); | ||
it('Filter using notNull', function(done){ | ||
db.event({canceled: ORM.notNull()}).find(expect('[{"id":3,"title":"Mapping Test","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":true}]', done)); | ||
}); | ||
it('Using multiple values', function(done){ | ||
db.event({id: 1, title:'Changed title'}).findOne(expect('{"id":1,"title":"Changed title","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":null}', done)); | ||
}); | ||
it('Using multiple values on the same column', function(done){ | ||
db.event({id: ORM.in([1, 2])}).find(expect('[{"id":2,"title":"Mapping Test","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":null},{"id":1,"title":"Changed title","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":null}]', done)); | ||
}); | ||
it('Records with the > operator', function(done){ | ||
db.event({id: ORM.gt(2)}).find(expect('[{"id":3,"title":"Mapping Test","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":true}]', done)); | ||
}); | ||
it('Records with the < operator', function(done){ | ||
db.event({id: ORM.lt(2)}).find(expect('[{"id":1,"title":"Changed title","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":null}]', done)); | ||
}); | ||
it('Records with the >= operator', function(done){ | ||
db.event({id: ORM.gte(2)}).find(expect('[{"id":2,"title":"Mapping Test","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":null},{"id":3,"title":"Mapping Test","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":true}]', done)); | ||
}); | ||
it('Records with the <= operator', function(done){ | ||
db.event({id: ORM.lte(2)}).find(expect('[{"id":2,"title":"Mapping Test","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":null},{"id":1,"title":"Changed title","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":null}]', done)); | ||
}); | ||
}); | ||
}); | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
160159
2969
0