sqlite-async
Advanced tools
Comparing version 1.1.3 to 1.1.4
{ | ||
"name": "sqlite-async", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "ES6 Promise-based interface to the sqlite3 module.", | ||
"main": "sqlite-async.js", | ||
"type": "module", | ||
"directories": { | ||
@@ -26,8 +27,8 @@ "test": "mocha" | ||
"homepage": "https://github.com/fhellwig/sqlite-async#readme", | ||
"dependencies": { | ||
"sqlite3": "^5.0.11" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^9.2.0" | ||
}, | ||
"dependencies": { | ||
"sqlite3": "^5.0.2" | ||
"mocha": "^10.0.0" | ||
} | ||
} |
@@ -10,3 +10,3 @@ # sqlite-async | ||
```javascript | ||
const Database = require('sqlite-async') | ||
import { Database } from 'sqlite-async': | ||
@@ -19,3 +19,3 @@ Database.open('test.db') | ||
... | ||
}) | ||
}): | ||
``` | ||
@@ -69,7 +69,7 @@ | ||
db.transaction((db) => { | ||
return Promise.all([ | ||
db.run('INSERT INTO test VALUES (2, "two")'), | ||
db.run('INSERT INTO test VALUES (2, "three")') | ||
]) | ||
}) | ||
return Promise.all([ | ||
db.run('INSERT INTO test VALUES (2, "two")'), | ||
db.run('INSERT INTO test VALUES (2, "three")') | ||
]); | ||
}); | ||
``` | ||
@@ -113,3 +113,3 @@ | ||
Copyright (c) 2021 Frank Hellwig | ||
Copyright (c) 2022 Frank Hellwig | ||
@@ -116,0 +116,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
@@ -5,4 +5,3 @@ /** | ||
const sqlite = require('sqlite3'); | ||
const pkg = require('./package.json'); // for sqlite3 version number | ||
import sqlite from 'sqlite3'; | ||
@@ -13,3 +12,3 @@ //----------------------------------------------------------------------------- | ||
class Database { | ||
export class Database { | ||
static get OPEN_READONLY() { | ||
@@ -28,3 +27,3 @@ return sqlite.OPEN_READONLY; | ||
static get SQLITE3_VERSION() { | ||
return pkg.dependencies.sqlite3.substring(1); | ||
return '5.0.11'; | ||
} | ||
@@ -62,3 +61,3 @@ | ||
} | ||
close(fn) { | ||
@@ -105,3 +104,3 @@ if (!this.db) { | ||
lastID: this.lastID, | ||
changes: this.changes, | ||
changes: this.changes | ||
}); | ||
@@ -274,3 +273,3 @@ } | ||
lastID: this.lastID, | ||
changes: this.changes, | ||
changes: this.changes | ||
}); | ||
@@ -329,7 +328,1 @@ } | ||
} | ||
//----------------------------------------------------------------------------- | ||
// Module Exports | ||
//----------------------------------------------------------------------------- | ||
module.exports = Database; |
@@ -1,4 +0,4 @@ | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
const Database = require('../sqlite-async'); | ||
import assert from 'assert'; | ||
import { unlink } from 'fs'; | ||
import { Database } from '../sqlite-async.js'; | ||
@@ -12,3 +12,5 @@ let db; | ||
it('should log the version number', function () { | ||
return console.log(' sqlite3 version: ' + Database.SQLITE3_VERSION); | ||
return console.log( | ||
' sqlite3 version: ' + Database.SQLITE3_VERSION | ||
); | ||
}); | ||
@@ -40,5 +42,11 @@ }); | ||
it('should update a value', function () { | ||
return db.run('UPDATE test SET name = "test" WHERE id = 1').then((result) => { | ||
assert.strictEqual(result.changes, 1, 'Expected one change in the database'); | ||
}); | ||
return db | ||
.run('UPDATE test SET name = "test" WHERE id = 1') | ||
.then((result) => { | ||
assert.strictEqual( | ||
result.changes, | ||
1, | ||
'Expected one change in the database' | ||
); | ||
}); | ||
}); | ||
@@ -50,3 +58,7 @@ }); | ||
return db.run('DELETE FROM test WHERE id = 2').then((result) => { | ||
assert.strictEqual(result.changes, 1, 'Expected one change in the database'); | ||
assert.strictEqual( | ||
result.changes, | ||
1, | ||
'Expected one change in the database' | ||
); | ||
}); | ||
@@ -61,3 +73,3 @@ }); | ||
id: 1, | ||
name: 'test', | ||
name: 'test' | ||
}); | ||
@@ -73,4 +85,4 @@ }); | ||
id: 1, | ||
name: 'test', | ||
}, | ||
name: 'test' | ||
} | ||
]); | ||
@@ -85,3 +97,3 @@ }); | ||
id: 1, | ||
name: 'test', | ||
name: 'test' | ||
}); | ||
@@ -98,3 +110,3 @@ }); | ||
db.run('INSERT INTO test VALUES (2, "two")'), | ||
db.run('INSERT INTO test VALUES (3, NULL)'), | ||
db.run('INSERT INTO test VALUES (3, NULL)') | ||
]); | ||
@@ -113,3 +125,7 @@ }) | ||
return db.all('SELECT * FROM test').then((rows) => { | ||
assert.strictEqual(rows.length, 1, 'Expected only one row in the database.'); | ||
assert.strictEqual( | ||
rows.length, | ||
1, | ||
'Expected only one row in the database.' | ||
); | ||
}); | ||
@@ -123,3 +139,3 @@ }); | ||
db.run('INSERT INTO test VALUES (2, "two")'), | ||
db.run('INSERT INTO test VALUES (3, "three")'), | ||
db.run('INSERT INTO test VALUES (3, "three")') | ||
]); | ||
@@ -130,3 +146,7 @@ }); | ||
return db.all('SELECT * FROM test').then((rows) => { | ||
assert.strictEqual(rows.length, 3, 'Expected three rows in the database.'); | ||
assert.strictEqual( | ||
rows.length, | ||
3, | ||
'Expected three rows in the database.' | ||
); | ||
}); | ||
@@ -137,5 +157,7 @@ }); | ||
it('should prepare a statement', function () { | ||
return db.prepare('SELECT * FROM test WHERE id = ?').then((_statement) => { | ||
statement = _statement; | ||
}); | ||
return db | ||
.prepare('SELECT * FROM test WHERE id = ?') | ||
.then((_statement) => { | ||
statement = _statement; | ||
}); | ||
}); | ||
@@ -156,3 +178,3 @@ }); | ||
id: 1, | ||
name: 'test', | ||
name: 'test' | ||
}); | ||
@@ -168,4 +190,4 @@ }); | ||
id: 1, | ||
name: 'test', | ||
}, | ||
name: 'test' | ||
} | ||
]); | ||
@@ -180,3 +202,3 @@ }); | ||
id: 1, | ||
name: 'test', | ||
name: 'test' | ||
}); | ||
@@ -190,3 +212,7 @@ }); | ||
return statement.run().then((result) => { | ||
assert.strictEqual(result.changes, 3, 'Expected three changes in the database'); | ||
assert.strictEqual( | ||
result.changes, | ||
3, | ||
'Expected three changes in the database' | ||
); | ||
return statement.finalize(); | ||
@@ -235,4 +261,4 @@ }); | ||
after(function (done) { | ||
fs.unlink('test.db', done); | ||
unlink('test.db', done); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
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
22510
537
Yes
Updatedsqlite3@^5.0.11