feat: tags autocomplete in page properties

This commit is contained in:
NGPixel
2020-02-02 16:24:27 -05:00
parent a1e0e4f27a
commit f4e3fd0954
5 changed files with 80 additions and 7 deletions

View File

@@ -129,6 +129,24 @@ module.exports = {
async tags (obj, args, context, info) {
return WIKI.models.tags.query().orderBy('tag', 'asc')
},
/**
* SEARCH TAGS
*/
async searchTags (obj, args, context, info) {
const results = await WIKI.models.tags.query()
.column('tag')
.where(builder => {
builder.andWhere(builderSub => {
if (WIKI.config.db.type === 'postgres') {
builderSub.where('tag', 'ILIKE', `%${args.query}%`)
} else {
builderSub.where('tag', 'LIKE', `%${args.query}%`)
}
})
})
.limit(5)
return results.map(r => r.tag)
},
/**
* FETCH PAGE TREE
*/