@lbu/store
Advanced tools
Comparing version 0.0.19 to 0.0.20
@@ -35,2 +35,4 @@ import { dirnameForModule } from "@lbu/stdlib"; | ||
export { FileCache } from "./src/file-cache.js"; | ||
export { JobQueueWorker, addJobToQueue } from "./src/queue.js"; | ||
@@ -37,0 +39,0 @@ |
{ | ||
"name": "@lbu/store", | ||
"version": "0.0.19", | ||
"version": "0.0.20", | ||
"description": "Postgres & S3-compatible wrappers for common things", | ||
@@ -17,4 +17,4 @@ "main": "./index.js", | ||
"dependencies": { | ||
"@lbu/insight": "^0.0.19", | ||
"@lbu/stdlib": "^0.0.19", | ||
"@lbu/insight": "^0.0.20", | ||
"@lbu/stdlib": "^0.0.20", | ||
"mime-types": "2.1.27", | ||
@@ -38,3 +38,3 @@ "minio": "7.0.16", | ||
}, | ||
"gitHead": "3bfc07c917ca2bc3fd7d8080c1f3507bcda51c31" | ||
"gitHead": "87bbba853bb050f7897c50ea291233297e2366e1" | ||
} |
@@ -1,2 +0,2 @@ | ||
// Generated by @lbu/code-gen at 2020-05-17T18:37:30.935Z | ||
// Generated by @lbu/code-gen at 2020-05-22T08:17:51.893Z | ||
/* eslint-disable no-unused-vars */ | ||
@@ -11,3 +11,3 @@ | ||
fileStoreSelect: (sql, where) => | ||
sql`SELECT id, bucket_name, content_length, content_type, filename, created_at, updated_at FROM file_store WHERE (${where.id} IS NULL OR id = ${where.id}) AND (${where.bucket_name} IS NULL OR bucket_name = ${where.bucket_name})`, | ||
sql`SELECT id, bucket_name, content_length, content_type, filename, created_at, updated_at FROM file_store WHERE (COALESCE(${where.id}, NULL) IS NULL OR id = ${where.id}) AND (COALESCE(${where.bucket_name}, NULL) IS NULL OR bucket_name = ${where.bucket_name})`, | ||
@@ -21,8 +21,9 @@ /** | ||
fileStoreUpdate: (sql, where, partial) => | ||
sql`UPDATE file_store SET ${sql(partial, ...Object.keys(partial))} WHERE (${ | ||
sql`UPDATE file_store SET ${sql( | ||
partial, | ||
...Object.keys(partial), | ||
)} WHERE (COALESCE(${where.id}, NULL) IS NULL OR id = ${ | ||
where.id | ||
} IS NULL OR id = ${where.id}) AND (${ | ||
}) AND (COALESCE(${where.bucket_name}, NULL) IS NULL OR bucket_name = ${ | ||
where.bucket_name | ||
} IS NULL OR bucket_name = ${ | ||
where.bucket_name | ||
}) RETURNING id, bucket_name, content_length, content_type, filename, created_at, updated_at`, | ||
@@ -36,3 +37,3 @@ | ||
fileStoreDelete: (sql, where) => | ||
sql`DELETE FROM file_store WHERE (${where.id} IS NULL OR id = ${where.id}) AND (${where.bucket_name} IS NULL OR bucket_name = ${where.bucket_name})`, | ||
sql`DELETE FROM file_store WHERE (COALESCE(${where.id}, NULL) IS NULL OR id = ${where.id}) AND (COALESCE(${where.bucket_name}, NULL) IS NULL OR bucket_name = ${where.bucket_name})`, | ||
@@ -59,3 +60,3 @@ /** | ||
sessionStoreSelect: (sql, where) => | ||
sql`SELECT id, expires, data FROM session_store WHERE (${where.id} IS NULL OR id = ${where.id})`, | ||
sql`SELECT id, expires, data FROM session_store WHERE (COALESCE(${where.id}, NULL) IS NULL OR id = ${where.id})`, | ||
@@ -72,3 +73,3 @@ /** | ||
...Object.keys(partial), | ||
)} WHERE (${where.id} IS NULL OR id = ${ | ||
)} WHERE (COALESCE(${where.id}, NULL) IS NULL OR id = ${ | ||
where.id | ||
@@ -83,3 +84,3 @@ }) RETURNING id, expires, data`, | ||
sessionStoreDelete: (sql, where) => | ||
sql`DELETE FROM session_store WHERE (${where.id} IS NULL OR id = ${where.id})`, | ||
sql`DELETE FROM session_store WHERE (COALESCE(${where.id}, NULL) IS NULL OR id = ${where.id})`, | ||
@@ -105,3 +106,3 @@ /** | ||
jobQueueSelect: (sql, where) => | ||
sql`SELECT id, is_complete, priority, scheduled_at, created_at, updated_at, name, data FROM job_queue WHERE (${where.id} IS NULL OR id = ${where.id}) AND (${where.name} IS NULL OR name = ${where.name})`, | ||
sql`SELECT id, is_complete, priority, scheduled_at, created_at, updated_at, name, data FROM job_queue WHERE (COALESCE(${where.id}, NULL) IS NULL OR id = ${where.id}) AND (COALESCE(${where.name}, NULL) IS NULL OR name = ${where.name})`, | ||
@@ -115,5 +116,8 @@ /** | ||
jobQueueUpdate: (sql, where, partial) => | ||
sql`UPDATE job_queue SET ${sql(partial, ...Object.keys(partial))} WHERE (${ | ||
sql`UPDATE job_queue SET ${sql( | ||
partial, | ||
...Object.keys(partial), | ||
)} WHERE (COALESCE(${where.id}, NULL) IS NULL OR id = ${ | ||
where.id | ||
} IS NULL OR id = ${where.id}) AND (${where.name} IS NULL OR name = ${ | ||
}) AND (COALESCE(${where.name}, NULL) IS NULL OR name = ${ | ||
where.name | ||
@@ -128,3 +132,3 @@ }) RETURNING id, is_complete, priority, scheduled_at, created_at, updated_at, name, data`, | ||
jobQueueDelete: (sql, where) => | ||
sql`DELETE FROM job_queue WHERE (${where.id} IS NULL OR id = ${where.id}) AND (${where.name} IS NULL OR name = ${where.name})`, | ||
sql`DELETE FROM job_queue WHERE (COALESCE(${where.id}, NULL) IS NULL OR id = ${where.id}) AND (COALESCE(${where.name}, NULL) IS NULL OR name = ${where.name})`, | ||
@@ -131,0 +135,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
// Generated by @lbu/code-gen at 2020-05-17T18:37:30.935Z | ||
// Generated by @lbu/code-gen at 2020-05-22T08:17:51.893Z | ||
/* eslint-disable no-unused-vars */ | ||
@@ -3,0 +3,0 @@ |
@@ -62,6 +62,35 @@ import { dirnameForModule } from "@lbu/stdlib"; | ||
/** | ||
* Get a list of migrations to be applied | ||
* @param {MigrateContext} mc | ||
* @return {({name: string, number: number, repeatable: boolean}[])|boolean} | ||
*/ | ||
export function getMigrationsToBeApplied(mc) { | ||
const list = filterMigrationsToBeApplied(mc); | ||
if (list.length === 0) { | ||
return false; | ||
} | ||
return list.map((it) => ({ | ||
name: `${it.namespace}/${it.name}`, | ||
number: it.number, | ||
repeatable: it.repeatable, | ||
})); | ||
} | ||
/** | ||
* @param {MigrateContext} mc | ||
*/ | ||
export async function runMigrations(mc) { | ||
const migrationFiles = filterMigrationsToBeApplied(mc); | ||
for (const migration of migrationFiles) { | ||
await runMigration(mc.sql, migration); | ||
} | ||
} | ||
/** | ||
* @param {MigrateContext} mc | ||
* @return {MigrateFile[]} | ||
*/ | ||
export function getMigrationsToBeApplied(mc) { | ||
function filterMigrationsToBeApplied(mc) { | ||
const result = []; | ||
@@ -83,13 +112,2 @@ for (const f of mc.files) { | ||
/** | ||
* @param {MigrateContext} mc | ||
*/ | ||
export async function runMigrations(mc) { | ||
const migrationFiles = getMigrationsToBeApplied(mc); | ||
for (const migration of migrationFiles) { | ||
await runMigration(mc.sql, migration); | ||
} | ||
} | ||
/** | ||
* @param {postgres} sql | ||
@@ -96,0 +114,0 @@ * @param {MigrateFile} migration |
49675
19
1403
24
+ Added@lbu/insight@0.0.20(transitive)
+ Added@lbu/stdlib@0.0.20(transitive)
- Removed@lbu/insight@0.0.19(transitive)
- Removed@lbu/stdlib@0.0.19(transitive)
Updated@lbu/insight@^0.0.20
Updated@lbu/stdlib@^0.0.20