Comparing version 6.2.0 to 6.3.0
@@ -63,2 +63,11 @@ 'use strict'; | ||
exist(id, callback) { | ||
if (id.toString().length > 127) { | ||
return this._error('exist', 'Invalid id length', id, Hoek.nextTick(callback)); | ||
} | ||
this._run(this._table.get(id).ne(null), 'exist', id, callback); | ||
} | ||
query(criteria, options, callback) { | ||
@@ -65,0 +74,0 @@ |
{ | ||
"name": "penseur", | ||
"description": "Lightweight RethinkDB wrapper", | ||
"version": "6.2.0", | ||
"version": "6.3.0", | ||
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)", | ||
@@ -6,0 +6,0 @@ "repository": "git://github.com/hueniverse/penseur", |
@@ -39,17 +39,2 @@ 'use strict'; | ||
it('fails on database error', (done) => { | ||
const db = new Penseur.Db('penseurtest'); | ||
db.table('invalid'); | ||
db.connect((err) => { | ||
expect(err).to.not.exist(); | ||
db.invalid.get(1, (err, item) => { | ||
expect(err).to.exist(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('returns the requested objects', (done) => { | ||
@@ -75,2 +60,17 @@ | ||
it('fails on database error', (done) => { | ||
const db = new Penseur.Db('penseurtest'); | ||
db.table('invalid'); | ||
db.connect((err) => { | ||
expect(err).to.not.exist(); | ||
db.invalid.get(1, (err, item) => { | ||
expect(err).to.exist(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('returns the requested objects (array of one)', (done) => { | ||
@@ -197,2 +197,55 @@ | ||
describe('exist()', () => { | ||
it('checks if record exists', (done) => { | ||
const db = new Penseur.Db('penseurtest'); | ||
db.establish(['test'], (err) => { | ||
expect(err).to.not.exist(); | ||
db.test.insert({ id: 1, a: 1 }, (err, keys) => { | ||
expect(err).to.not.exist(); | ||
db.test.exist(1, (err, exists) => { | ||
expect(err).to.not.exist(); | ||
expect(exists).to.be.true(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
it('checks if record does not exists', (done) => { | ||
const db = new Penseur.Db('penseurtest'); | ||
db.establish(['test'], (err) => { | ||
expect(err).to.not.exist(); | ||
db.test.exist(1, (err, exists) => { | ||
expect(err).to.not.exist(); | ||
expect(exists).to.be.false(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('errors on invalid id', (done) => { | ||
const db = new Penseur.Db('penseurtest'); | ||
db.establish(['test'], (err) => { | ||
expect(err).to.not.exist(); | ||
db.test.exist('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', (err, result) => { | ||
expect(err).to.exist(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe('query()', () => { | ||
@@ -199,0 +252,0 @@ |
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
192741
4601