|
|
@ -246,14 +246,31 @@ module.exports = {
|
|
|
|
* FETCH PAGE LINKS
|
|
|
|
* FETCH PAGE LINKS
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
async links (obj, args, context, info) {
|
|
|
|
async links (obj, args, context, info) {
|
|
|
|
let results = []
|
|
|
|
let results;
|
|
|
|
|
|
|
|
|
|
|
|
results = await WIKI.models.knex('pages')
|
|
|
|
if (WIKI.config.db.type === 'mysql' || WIKI.config.db.type === 'mariadb' || WIKI.config.db.type === 'sqlite') {
|
|
|
|
.column({ id: 'pages.id' }, { path: 'pages.path' }, 'title', { link: 'pageLinks.path' }, { locale: 'pageLinks.localeCode' })
|
|
|
|
results = await WIKI.models.knex('pages')
|
|
|
|
.fullOuterJoin('pageLinks', 'pages.id', 'pageLinks.pageId')
|
|
|
|
.column({ id: 'pages.id' }, { path: 'pages.path' }, 'title', { link: 'pageLinks.path' }, { locale: 'pageLinks.localeCode' })
|
|
|
|
.where({
|
|
|
|
.leftJoin('pageLinks', 'pages.id', 'pageLinks.pageId')
|
|
|
|
'pages.localeCode': args.locale
|
|
|
|
.where({
|
|
|
|
})
|
|
|
|
'pages.localeCode': args.locale
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.unionAll(
|
|
|
|
|
|
|
|
WIKI.models.knex('pageLinks')
|
|
|
|
|
|
|
|
.column({ id: 'pages.id' }, { path: 'pages.path' }, 'title', { link: 'pageLinks.path' }, { locale: 'pageLinks.localeCode' })
|
|
|
|
|
|
|
|
.leftJoin('pages', 'pageLinks.pageId', 'pages.id')
|
|
|
|
|
|
|
|
.where({
|
|
|
|
|
|
|
|
'pages.localeCode': args.locale
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
results = await WIKI.models.knex('pages')
|
|
|
|
|
|
|
|
.column({ id: 'pages.id' }, { path: 'pages.path' }, 'title', { link: 'pageLinks.path' }, { locale: 'pageLinks.localeCode' })
|
|
|
|
|
|
|
|
.fullOuterJoin('pageLinks', 'pages.id', 'pageLinks.pageId')
|
|
|
|
|
|
|
|
.where({
|
|
|
|
|
|
|
|
'pages.localeCode': args.locale
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return _.reduce(results, (result, val) => {
|
|
|
|
return _.reduce(results, (result, val) => {
|
|
|
|
// -> Check if user has access to source and linked page
|
|
|
|
// -> Check if user has access to source and linked page
|
|
|
|