Примеры

Сложный фильтр

const leads = await Global.ns._clients.app._leads.search()
        .where((f, g) => {
            let opperands: Filter[] = [];
            opperands.push(f.__deletedAt.eq(null));
            opperands.push(f.__createdAt.gte(Context.data.start_date!));
            opperands.push(f.__createdAt.lte(Context.data.end_date!));
            if (Context.data.status?.length) {
                let filterStatus: Filter[] = [];
                for (const adress of Context.data.adresses) {
                    filterStatus.push(f._address.eq(adress))
                }
                opperands.push(g.or(...filterStatus))
            }
            if (Context.data.companyes?.length) {
                let filterChannel: Filter[] = [];
                for (const company of Context.data.companies) {
                    filterChannel.push(f._companies.link(company))
                }
                opperands.push(g.or(...filterChannel))
            }
            return g.and(...opperands)
        })
        .size(10000)
        .all()

 

Ожидание загрузки всех скриптов

$(function() {
    // Загрузка внешних скриптов
    const loadScript = url => new Promise(resolve => {
        const script = document.createElement('script')
        script.addEventListener('load', () => {
            resolve()
        })
        script.src = url
        document.body.append(script)
    })

    const srcIndex = loadScript('https://cdn.amcharts.com/lib/5/index.js')
    const srcXY = loadScript('https://cdn.amcharts.com/lib/5/xy.js')
    const srcAm = loadScript('https://cdn.amcharts.com/lib/5/themes/Animated.js')

    Promise.all([srcIndex, srcXY, srcAm])
        .then(([srcIndex, srcXY, srcAm]) => {
            console.log('Скрипт index.js загружен')
            console.log('Скрипт xy.js загружен')
            console.log('Скрипт Animated.js загружен')
            amLoadScript()
        })

    function amLoadScript() {
       //
    }
});