fix: objection 2 changes

This commit is contained in:
NGPixel 2020-01-24 19:20:53 -05:00
parent e7b5457354
commit 988ba3f616
4 changed files with 7 additions and 7 deletions

View File

@ -30,7 +30,7 @@ module.exports = {
passport.deserializeUser(async (id, done) => {
try {
const user = await WIKI.models.users.query().findById(id).modifyEager('groups', builder => {
const user = await WIKI.models.users.query().findById(id).withGraphFetched('groups').modifyGraph('groups', builder => {
builder.select('groups.id', 'permissions')
})
if (user) {

View File

@ -116,7 +116,7 @@ module.exports = class PageHistory extends Model {
authorName: 'author.name'
}
])
.joinRelation('author')
.joinRelated('author')
.where({
'pageHistory.pageId': pageId
})
@ -138,7 +138,7 @@ module.exports = class PageHistory extends Model {
authorName: 'author.name'
}
])
.joinRelation('author')
.joinRelated('author')
.where({
'pageHistory.pageId': pageId
})

View File

@ -702,8 +702,8 @@ module.exports = class Page extends Model {
creatorEmail: 'creator.email'
}
])
.joinRelation('author')
.joinRelation('creator')
.joinRelated('author')
.joinRelated('creator')
.eagerAlgorithm(Model.JoinEagerAlgorithm)
.eager('tags(selectTags)', {
selectTags: builder => {

View File

@ -331,7 +331,7 @@ module.exports = class User extends Model {
static async refreshToken(user) {
if (_.isSafeInteger(user)) {
user = await WIKI.models.users.query().findById(user).eager('groups').modifyEager('groups', builder => {
user = await WIKI.models.users.query().findById(user).withGraphFetched('groups').modifyGraph('groups', builder => {
builder.select('groups.id', 'permissions')
})
if (!user) {
@ -339,7 +339,7 @@ module.exports = class User extends Model {
throw new WIKI.Error.AuthGenericError()
}
} else if (_.isNil(user.groups)) {
await user.$relatedQuery('groups').select('groups.id', 'permissions')
user.groups = await user.$relatedQuery('groups').select('groups.id', 'permissions')
}
return {