本文整理汇总了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;未经允许,请勿转载。 |
请发表评论