-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_route.json
7 lines (7 loc) · 3.36 KB
/
db_route.json
1
2
3
4
5
6
7
{"total_rows":5,"offset":0,"rows":[
{"id":"_design/views","key":"_design/views","value":{"rev":"51-7dd53a1a60e258d64287b796574d2024"},"doc":{"_id":"_design/views","_rev":"51-7dd53a1a60e258d64287b796574d2024","views":{"getRoutesDetailed":{"map":"function(doc){\n /**\n * A Route contains checkpoints that reference ids of Locations.\n *\n * Major: doc.type=='route'\n * Minor: doc.type=='location'\n *\n * A Route.checkpoint --(1-N)--> multiple Location.ids.\n * - Precondition: call query with include_docs=true option.\n * - All emit-calls receive the valueof the key-value-tuple.\n * - The value of the minor emit-call contains an object with `_id` assigned to the id of the minor document. => This enables loading the whole document for each reference.\n * \n *\n * @see https://docs.couchdb.org/en/stable/ddocs/views/joins.html#linked-documents\n */\n \n if(doc.type == 'route'){\n emit([doc.value, 0], null)\n \n if(doc.checkpoints){\n for(let i in doc.checkpoints){\n emit([doc.value, Number(i)+1], {_id: doc.checkpoints[i].locationID});\n }\n }\n }\n}"}},"validate_doc_update":"function(newDoc, oldDoc, userCtx, secObj){\n\n /**\n * Case: delete a document.\n * Check whether the excuting user is an admin. \n */\n if(newDoc._deleted === true){\n if((userCtx.roles.indexOf('_admin') !== -1) || (userCtx.name == oldDoc.name)) {\n return;\n }else{\n throw({forbidden: 'Only admins may delete other user docs.'});\n }\n }\n\n /**\n * Case: create a document.\n * Ensure that doc.type matches an allowed type.\n */\n const allowedTypes = new Set(['route', 'checkpoint', 'location']);\n if(newDoc && !allowedTypes.has(newDoc.type)){\n throw({forbidden: 'Invalid type.'});\n }\n}","language":"javascript"}},
{"id":"finkenkrug-finkenstr-du","key":"finkenkrug-finkenstr-du","value":{"rev":"1-d8108a2b255c04c6cb9474b978c2927c"},"doc":{"_id":"finkenkrug-finkenstr-du","_rev":"1-d8108a2b255c04c6cb9474b978c2927c","type":"location","name":"Finkenkrug","start":"2024-06-10T13:00:00.000Z","url":"https://maps.app.goo.gl/a4VPM3jij5SATjKD8","lat":51.42152404785156,"long":6.784869194030762}},
{"id":"ichiraku-sushi-wallstr-du","key":"ichiraku-sushi-wallstr-du","value":{"rev":"1-9ab192c2ba8b4fd5478e60f9fa393e37"},"doc":{"_id":"ichiraku-sushi-wallstr-du","_rev":"1-9ab192c2ba8b4fd5478e60f9fa393e37","type":"location","name":"Ichiraku Sushi & Grill","start":"2024-06-10T18:00:00.000Z","url":"https://maps.app.goo.gl/62CJUKNDcnoLdGdo7","lat":51.4315071105957,"long":6.763126373291016}},
{"id":"simply-coffee-moselstr-du","key":"simply-coffee-moselstr-du","value":{"rev":"1-a96992cb33df3234a0d63d6629498b53"},"doc":{"_id":"simply-coffee-moselstr-du","_rev":"1-a96992cb33df3234a0d63d6629498b53","type":"location","name":"Simply Coffee","url":"https://maps.app.goo.gl/dmNQwaXu36zT5Rtz6","lat":51.43611145019531,"long":6.770381927490234}},
{"id":"stormy-saturday","key":"stormy-saturday","value":{"rev":"7-c696376630cef0cfedcb250dfbdaf45b"},"doc":{"_id":"stormy-saturday","_rev":"7-c696376630cef0cfedcb250dfbdaf45b","name":"Stormy saturday","type":"route","checkpoints":[{"locationID":"simply-coffee-moselstr-du","start":"2024-06-10T12:00:00.000Z"},{"locationID":"finkenkrug-finkenstr-du","start":"2024-06-10T16:00:00.000Z"},{"locationID":"ichiraku-sushi-wallstr-du","start":"2024-06-10T20:00:00.000Z"}]}}
]}