本文整理匯總了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')
}