feat: tags autocomplete in page properties
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user