Source

externalCode/sqlite.js

/**
 * @typedef {Function} LessonEntitiesCallback
 * @param {Object} columns Lesson columns
 * @return {Object} New columns
 */

/**
 * @typedef {Function} LessonEntitiesCallback
 * @param {Object} columns Lesson columns
 * @return {Object} New columns
 */

/**
 * @class
 * Sqlite Hooks.
 * Instance name: sqliteApi
  
   You can use it to modify sqlite database options for your app.
 * @example
 * externalCodeSetup.sqliteApi.METHOD_NAME
 */
export class Sqlite {
	enabled = true;

	lessonEntities = columns => columns;

	/**
	 * You can use this to disable sqlite database which is used for storing offline courses.
	 * @method
	 * @example
	 * externalCodeSetup.sqliteApi.disableSqlite()
	 */
	disableSqlite = () => (this.enabled = false);

	/**
	 * You can use this to customize sqlite LessonModel which is used for storing offline lesson.
	 * For example, you can add a new column or modify the existing columns.
	 * @method
	 * @param {LessonEntitiesCallback} columns
	 * @example
	 *
	 * externalCodeSetup.sqliteApi.setLessonEntities(props => {
	 *    return {
	 *      ...props,
	 *      new_column_name_1: {type: "text", nullable: true},
	 *      new_column_name_2: {type: "text", nullable: true},
	 *    };
	 * })
	 */
	setLessonEntities = columns => {
		this.lessonEntities = columns;
	};
}