wiki/server/models/pages.js
/**
   * Save a Page Model Instance to Cache
   *
   * @param {Object} page Page Model Instance
   * @returns {Promise} Promise with no value
   */
Save a Page Model Instance to Cache
@param {Object} page Page Model Instance
@returns {Promise} Promise with no value
Save a Page Model Instance to Cache @param { Object } page Page Model Instance @returns { Promise } Promise with no value
static async savePageToCache(page) {
    const cachePath = path.resolve(WIKI.ROOTPATH, WIKI.config.dataPath, `cache/${page.hash}.bin`)
    await fs.outputFile(cachePath, WIKI.models.pages.cacheSchema.encode({
      id: page.id,
      authorId: page.authorId,
      authorName: page.authorName,
      createdAt: page.createdAt,
      creatorId: page.creatorId,
      creatorName: page.creatorName,
      description: page.description,
      extra: {
        css: _.get(page, 'extra.css', ''),
        js: _.get(page, 'extra.js', '')
      },
      isPrivate: page.isPrivate === 1 || page.isPrivate === true,
      isPublished: page.isPublished === 1 || page.isPublished === true,
      publishEndDate: page.publishEndDate,
      publishStartDate: page.publishStartDate,
      render: page.render,
      tags: page.tags.map(t => _.pick(t, ['tag', 'title'])),
      title: page.title,
      toc: _.isString(page.toc) ? page.toc : JSON.stringify(page.toc),
      updatedAt: page.updatedAt
    }))
  }
static async savePageToCache ( page ) { const cachePath = path . resolve ( WIKI . ROOTPATH , WIKI . config . dataPath , ` ${ page . hash } ` ) await fs . outputFile ( cachePath , WIKI . models . pages . cacheSchema . encode ( { id : page . id , authorId : page . authorId , authorName : page . authorName , createdAt : page . createdAt , creatorId : page . creatorId , creatorName : page . creatorName , description : page . description , extra : { css : _ . get ( page , 'extra.css' , '' ) , js : _ . get ( page , 'extra.js' , '' ) } , isPrivate : page . isPrivate === 1 || page . isPrivate === true , isPublished : page . isPublished === 1 || page . isPublished === true , publishEndDate : page . publishEndDate , publishStartDate : page . publishStartDate , render : page . render , tags : page . tags . map ( t => _ . pick ( t , [ 'tag' , 'title' ] ) ) , title : page . title , toc : _ . isString ( page . toc ) ? page . toc : JSON . stringify ( page . toc ) , updatedAt : page . updatedAt } ) ) }
Save a Page Model Instance to Cache
 @param {Object} page Page Model Instance
 @returns {Promise} Promise with no value
Save a Page Model Instance to Cache @param { Object } page Page Model Instance @returns { Promise } Promise with no value