@@ -10,14 +10,6 @@ import logger from '@/logger.js';
1010import { CourseLookup } from '@vue-skuilder/db' ;
1111import { courseDBDesignDocs } from '../design-docs.js' ;
1212
13- /**
14- * Fake fcn to allow usage in couchdb map fcns which, after passing
15- * through `.toString()`, are applied to all courses
16- */
17- function emit ( key ?: unknown , value ?: unknown ) : [ unknown , unknown ] {
18- return [ key , value ] ;
19- }
20-
2113function getCourseDBName ( courseID : string ) : string {
2214 return `coursedb-${ courseID } ` ;
2315}
@@ -59,9 +51,6 @@ function insertDesignDoc(
5951 } ) ;
6052}
6153
62-
63-
64-
6554export async function initCourseDBDesignDocInsert ( ) : Promise < void > {
6655 const courses = await CourseLookup . allCourses ( ) ;
6756 courses . forEach ( ( c ) => {
@@ -71,7 +60,7 @@ export async function initCourseDBDesignDocInsert(): Promise<void> {
7160 } ) ;
7261
7362 // Update security object for public courses
74- const courseDB = CouchDB . use ( getCourseDBName ( c . _id ) ) ;
63+ const courseDB = CouchDB . use < CourseConfig > ( getCourseDBName ( c . _id ) ) ;
7564 courseDB
7665 . get ( 'CourseConfig' )
7766 . then ( ( configDoc ) => {
@@ -87,6 +76,8 @@ export async function initCourseDBDesignDocInsert(): Promise<void> {
8776 } ,
8877 } ;
8978 courseDB
79+ // @ts -expect-error allow insertion of _security document.
80+ // db scoped as ConfigDoc to make the read easier.
9081 . insert ( secObj as nano . MaybeDocument , '_security' )
9182 . then ( ( ) => {
9283 logger . info (
0 commit comments