本文整理汇总了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
}
示例2: DB
.then(() =>
DB({
path: config.knex.connection.filename,
migrate: {
force: false,
migrationsPath: config.knex.migrations.directory
}
})
.connection()
示例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)
}
示例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
}
示例5: fetchTags
export function fetchTags(): Promise<TagType[]> {
return DB().query<TagType>('select * from tags order by slug')
}