How to filter jsreport.documentStore.collection by asset path in order to check asset exist in before render script?

  • Hi sir,
    i have found below script which check asset (image) exist, if asset not exist then an alternate image will be used. But in my case i have to check whether an asset exist in particular path.But i dont know how to filter document store using asset path?

    const jsreport = require('jsreport-proxy')
    async function beforeRender(req, res) {
    const logoAsset = await jsreport.documentStore.collection('assets').findOne({ name: 'logo.png' })
    if (logoAsset) { = 'logo.png'
    } else { = 'another.png'

    Could you please reply with an example?

  • here you go

    async function beforeRender (req, res) {
        const jsreport = require('jsreport-proxy')
        const searchResult = await jsreport.folders.resolveEntityFromPath('/myasset.txt', 'assets')
        if (searchResult) {
            req.template.content = searchResult.entity.content.toString()

Log in to reply

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.