UNPKG

@grby/nlpx

Version:

two way sync for negative lab pro and lightroom

19 lines (16 loc) 829 B
import { and, eq, like } from "drizzle-orm"; import { CONSTANTS } from "../../constants"; import type { DB, GeneralEntries, GeneralEntriesKey } from "../../types"; import { agPhotoPropertySpec, agSearchablePhotoProperty } from "../schema"; const getGeneralEntries = (db: DB, id: number) => db .select({ key: agPhotoPropertySpec.key, value: agSearchablePhotoProperty.internalValue, }) .from(agSearchablePhotoProperty) .innerJoin(agPhotoPropertySpec, eq(agPhotoPropertySpec.id_local, agSearchablePhotoProperty.propertySpec)) .where(and(eq(agSearchablePhotoProperty.photo, id), like(agPhotoPropertySpec.key, CONSTANTS.NLP_PROPERTY_MATCH))) .all() .reduce((result, { key, value }) => ({ ...result, [key as GeneralEntriesKey]: value }), {} as GeneralEntries); export { getGeneralEntries };