dyomedea/src/db/rte.ts

34 lines
654 B
TypeScript
Raw Normal View History

2022-11-08 21:02:06 +00:00
import getUri from '../lib/ids';
import { putNewGpx } from './gpx';
import { put } from './lib';
export const emptyRte: Rte = {
name: undefined,
cmt: undefined,
desc: undefined,
src: undefined,
link: undefined,
number: 0,
type: undefined,
extensions: undefined,
rtept: undefined,
};
export const putNewRte = async (id?: IdRte | IdGpx) => {
let finalId = { ...id };
if (!('rte' in finalId)) {
const gpxId = await putNewGpx(id);
finalId = { ...gpxId, rte: 0 };
2022-11-08 21:02:06 +00:00
}
const uri = getUri('rte', finalId);
await put(
uri,
'rte',
(rte) => {
return rte;
},
emptyRte
);
return finalId as IdRte;
};