parent
7414553dae
commit
78d7ce90b9
3 changed files with 30 additions and 2 deletions
@ -0,0 +1,20 @@ |
|||||||
|
import { DELETED } from '../../consts'; |
||||||
|
|
||||||
|
import { write } from '../../accessModule'; |
||||||
|
import { buildDeleteRequestHandler } from '../buildDeleteRequestHandler'; |
||||||
|
import join from '../../join'; |
||||||
|
|
||||||
|
export const deleteFence = buildDeleteRequestHandler({ |
||||||
|
delete: async (fenceUuids) => { |
||||||
|
const wcode = await write( |
||||||
|
`UPDATE fences
|
||||||
|
SET fence_arguments = '${DELETED}' |
||||||
|
WHERE fence_uuid IN (${join(fenceUuids, { |
||||||
|
elementWrapper: "'", |
||||||
|
separator: ',', |
||||||
|
})});`,
|
||||||
|
); |
||||||
|
|
||||||
|
if (wcode !== 0) throw Error(`Write exited with code ${wcode}`); |
||||||
|
}, |
||||||
|
}); |
@ -1,2 +1,3 @@ |
|||||||
|
export * from './deleteFence'; |
||||||
export * from './getFence'; |
export * from './getFence'; |
||||||
export * from './getFenceTemplate'; |
export * from './getFenceTemplate'; |
||||||
|
@ -1,9 +1,16 @@ |
|||||||
import express from 'express'; |
import express from 'express'; |
||||||
|
|
||||||
import { getFence, getFenceTemplate } from '../lib/request_handlers/fence'; |
import { |
||||||
|
deleteFence, |
||||||
|
getFence, |
||||||
|
getFenceTemplate, |
||||||
|
} from '../lib/request_handlers/fence'; |
||||||
|
|
||||||
const router = express.Router(); |
const router = express.Router(); |
||||||
|
|
||||||
router.get('/', getFence).get('/template', getFenceTemplate); |
router |
||||||
|
.delete('/:uuid?', deleteFence) |
||||||
|
.get('/', getFence) |
||||||
|
.get('/template', getFenceTemplate); |
||||||
|
|
||||||
export default router; |
export default router; |
||||||
|
Loading…
Reference in new issue