app: lists on meta tables, schema-qualified SQL, typed columns
- lists read/write real lists.* tables via meta.tables/meta.columns and the SECURITY DEFINER meta functions; typed extra columns in the item forms - old numeric list URLs 308-redirect to the slug - include_recurring is boolean, osu accuracy/pp/rate numeric - raw SQL qualified with the new schemas
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { db } from '#lib/server/db/index.js';
|
||||
import { blogArticles, lists } from '#lib/server/db/schema/index.js';
|
||||
import { blogArticles, metaTables } from '#lib/server/db/schema/index.js';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
export function slugify(title: string, fallback = 'article'): string {
|
||||
@@ -32,7 +32,10 @@ export async function uniqueListSlug(name: string): Promise<string> {
|
||||
const base = slugify(name, 'list');
|
||||
let slug = base;
|
||||
let suffix = 2;
|
||||
while ((await db.select({ id: lists.id }).from(lists).where(eq(lists.slug, slug))).length > 0) {
|
||||
while (
|
||||
(await db.select({ id: metaTables.id }).from(metaTables).where(eq(metaTables.slug, slug)))
|
||||
.length > 0
|
||||
) {
|
||||
slug = `${base}-${suffix++}`;
|
||||
}
|
||||
return slug;
|
||||
|
||||
Reference in New Issue
Block a user