當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript no-generators.default函數代碼示例

本文整理匯總了TypeScript中sqlite3-helper/no-generators.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: fetchPhotoDetail

export async function fetchPhotoDetail(photoId: PhotoId): Promise<PhotoDetail> {
    const [ tags, versions ] = await Promise.all([
        DB().queryColumn<string>('title', 'select title from tags where id in (select tag_id from photos_tags where photo_id = ?) order by slug', photoId),
        DB().query<VersionType>('select * from versions where photo_id = ? order by version', photoId)
    ])

    return { tags, versions } as PhotoDetail

    // TODO
    //const lastVersion = photo.versions[photo.versions.length - 1]
    //photo.non_raw = lastVersion.output || photo.non_raw
}
開發者ID:m0g,項目名稱:ansel,代碼行數:12,代碼來源:PhotoStore.ts

示例2: DB

 .then(() =>
     DB({
         path: config.knex.connection.filename,
         migrate: {
             force: false,
             migrationsPath: config.knex.migrations.directory
         }
     })
     .connection()
開發者ID:m0g,項目名稱:ansel,代碼行數:9,代碼來源:entry.ts

示例3: DB

export async function fetchSections(filter: PhotoFilter): Promise<PhotoSection[]> {
    const filterWhere = createWhereForFilter(filter)
    const sql = `select date as id, date as title, count(*) as count from photos where ${filterWhere.sql} group by date order by date desc`
    return await DB().query<PhotoSection>(sql, ...filterWhere.params)
}
開發者ID:m0g,項目名稱:ansel,代碼行數:5,代碼來源:PhotoStore.ts

示例4: processNextStorePhotoTags

async function processNextStorePhotoTags(job: StorePhotoTagsJob): Promise<TagType[] | null> {
    const { photoId, photoTags } = job
    const photoTagsSlugged = photoTags.map(tag => slug(tag))
    let updatedTags: TagType[] | null = null

    await DB().query('BEGIN')
    try {
        const existingTags = await DB().query<{ id: number, slug: string }>(`select id, slug from tags where slug in (${toSqlStringCsv(photoTagsSlugged)})`)
        const tagIdBySlug = {}
        for (const tagInfo of existingTags) {
            tagIdBySlug[tagInfo.slug] = tagInfo.id
        }

        const photoTagMappings: { photo_id: PhotoId, tag_id: TagId }[] = []
        for (let tagIndex = 0, tagCount = photoTags.length; tagIndex < tagCount; tagIndex++) {
            const tagSlugged = photoTagsSlugged[tagIndex]
            let tagId = tagIdBySlug[tagSlugged]
            if (!tagId) {
                tagId = await DB().insert('tags', {
                    title: photoTags[tagIndex],
                    slug: tagSlugged,
                    created_at: Date.now()
                })
                tagsHaveChanged = true
            }
            photoTagMappings.push({ photo_id: photoId, tag_id: tagId })
        }

        const deletedCount = (await DB().run('delete from photos_tags where photo_id = ?', photoId)).changes
        if (deletedCount != 0) {
            tagsHaveBeenRemoved = true
        }
        if (photoTagMappings.length > 0) {
            await DB().insert('photos_tags', photoTagMappings)
        }

        if (storePhotoTagsQueue.getQueueLength() === 0) {
            // Clean up obsolete tags
            if (tagsHaveBeenRemoved) {
                tagsHaveBeenRemoved = false
                const deletedCount = (await DB().run('delete from tags where id not in (select tag_id from photos_tags group by tag_id)')).changes
                if (deletedCount !== 0) {
                    tagsHaveChanged = true
                }
            }

            if (tagsHaveChanged) {
                tagsHaveChanged = false
                updatedTags = await fetchTags()
            }
        }

        await DB().query('END')
    } catch (error) {
        console.error('Setting tags for photo failed', error)
        await DB().query('ROLLBACK')
        throw error
    }

    return updatedTags
}
開發者ID:m0g,項目名稱:ansel,代碼行數:61,代碼來源:TagStore.ts

示例5: fetchTags

export function fetchTags(): Promise<TagType[]> {
    return DB().query<TagType>('select * from tags order by slug')
}
開發者ID:m0g,項目名稱:ansel,代碼行數:3,代碼來源:TagStore.ts


注:本文中的sqlite3-helper/no-generators.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。