First version of notes, also allowing to delete wpts

This commit is contained in:
vdv committed 2023-03-06 16:45:20 +01:00
1 parent bf179a4b6d
commit adbbb3e356
7 files changed
+262 -53

No files matched your search

-11
View File
@@ -42,17 +42,6 @@ interface Bounds_ {
maxlon: number;
}
export enum Category {
NOTE = 'note',
POI = 'poi',
UNKNOWN = '',
}
export enum SubCategory {
ACCOMMODATION = 'accommodation',
UNKNOWN = '',
}
interface Extensions {
'dyo:speed'?: number;
'dyo:course'?: number;
+15 -1
View File
@@ -1,6 +1,6 @@
import getUri from '../lib/ids';
import { putNewGpx } from './gpx';
import { get, put } from './lib';
import { get, getFamily, put } from './lib';
export const emptyWpt: Wpt = {
$: { lat: 0, lon: 0 },
@@ -62,3 +62,17 @@ export const getWpt = async (params: any) => {
const doc = await get(id);
return doc.doc;
};
export const deleteWpt = async (params: any) => {
const { id } = params;
const docs = await getFamily(id, { include_docs: false });
console.log({ caller: 'deleteWpt' }, id, docs);
const deletedDocs = docs.rows.reverse().map((doc: any) => ({
_deleted: true,
_id: doc.id,
_rev: doc.value.rev,
}));
console.log({ caller: 'deleteWpt' }, id, docs, deletedDocs);
await db.bulkDocs(deletedDocs);
return id;
};