more advanced comparison, synced with how content hash is computed

This commit is contained in:
azivner
2017-11-29 19:56:14 -05:00
parent d21d5d4350
commit cd1ce48564
2 changed files with 51 additions and 20 deletions

13
sql.js
View File

@@ -24,6 +24,18 @@ async function getResults(db, query, params = []) {
return await wrap(db, async db => db.all(query, ...params));
}
async function getIndexed(db, column, query, params = []) {
const results = await getResults(db, query, params);
const map = {};
for (const row of results) {
map[row[column]] = row;
}
return map;
}
async function getMap(db, query, params = []) {
const map = {};
const results = await getResults(db, query, params);
@@ -70,6 +82,7 @@ module.exports = {
getSingleResult,
getSingleResultOrNull,
getResults,
getIndexed,
getMap,
getFlattenedResults,
execute