Add missing relation endpoints for content_mentor migration
- GET /api/objects?picture_id=X filter via object_pictures join - GET /api/objects/:id/words — full word details - GET /api/objects/:id/pairs — pairs with nested question + statements - GET /api/words?titel_de=X case-insensitive filter - GET /api/pictures/:id/words — full word details - DELETE /api/pictures/:id/words/:wordId — convenience unlink Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,10 +12,12 @@ const STATUS_TIMESTAMP = {
|
||||
// GET /api/words
|
||||
router.get('/', async (req, res, next) => {
|
||||
try {
|
||||
const { status, limit = 50, offset = 0 } = req.query;
|
||||
const { status, titel_de, limit = 50, offset = 0 } = req.query;
|
||||
const params = [Math.min(parseInt(limit), 500), parseInt(offset)];
|
||||
const where = status ? `WHERE w.status = $3` : '';
|
||||
if (status) params.push(status);
|
||||
const conditions = [];
|
||||
if (status) { conditions.push(`w.status = $${params.length + 1}`); params.push(status); }
|
||||
if (titel_de) { conditions.push(`lower(w.titel_de) = lower($${params.length + 1})`); params.push(titel_de); }
|
||||
const where = conditions.length ? `WHERE ${conditions.join(' AND ')}` : '';
|
||||
const result = await query(
|
||||
`SELECT w.*,
|
||||
COALESCE(json_agg(DISTINCT p.id) FILTER (WHERE p.id IS NOT NULL), '[]') AS picture_ids,
|
||||
|
||||
Reference in New Issue
Block a user