Commit 988ba3f6 authored by NGPixel's avatar NGPixel

fix: objection 2 changes

parent e7b54573
...@@ -30,7 +30,7 @@ module.exports = { ...@@ -30,7 +30,7 @@ module.exports = {
passport.deserializeUser(async (id, done) => { passport.deserializeUser(async (id, done) => {
try { 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') builder.select('groups.id', 'permissions')
}) })
if (user) { if (user) {
......
...@@ -116,7 +116,7 @@ module.exports = class PageHistory extends Model { ...@@ -116,7 +116,7 @@ module.exports = class PageHistory extends Model {
authorName: 'author.name' authorName: 'author.name'
} }
]) ])
.joinRelation('author') .joinRelated('author')
.where({ .where({
'pageHistory.pageId': pageId 'pageHistory.pageId': pageId
}) })
...@@ -138,7 +138,7 @@ module.exports = class PageHistory extends Model { ...@@ -138,7 +138,7 @@ module.exports = class PageHistory extends Model {
authorName: 'author.name' authorName: 'author.name'
} }
]) ])
.joinRelation('author') .joinRelated('author')
.where({ .where({
'pageHistory.pageId': pageId 'pageHistory.pageId': pageId
}) })
......
...@@ -702,8 +702,8 @@ module.exports = class Page extends Model { ...@@ -702,8 +702,8 @@ module.exports = class Page extends Model {
creatorEmail: 'creator.email' creatorEmail: 'creator.email'
} }
]) ])
.joinRelation('author') .joinRelated('author')
.joinRelation('creator') .joinRelated('creator')
.eagerAlgorithm(Model.JoinEagerAlgorithm) .eagerAlgorithm(Model.JoinEagerAlgorithm)
.eager('tags(selectTags)', { .eager('tags(selectTags)', {
selectTags: builder => { selectTags: builder => {
......
...@@ -331,7 +331,7 @@ module.exports = class User extends Model { ...@@ -331,7 +331,7 @@ module.exports = class User extends Model {
static async refreshToken(user) { static async refreshToken(user) {
if (_.isSafeInteger(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') builder.select('groups.id', 'permissions')
}) })
if (!user) { if (!user) {
...@@ -339,7 +339,7 @@ module.exports = class User extends Model { ...@@ -339,7 +339,7 @@ module.exports = class User extends Model {
throw new WIKI.Error.AuthGenericError() throw new WIKI.Error.AuthGenericError()
} }
} else if (_.isNil(user.groups)) { } else if (_.isNil(user.groups)) {
await user.$relatedQuery('groups').select('groups.id', 'permissions') user.groups = await user.$relatedQuery('groups').select('groups.id', 'permissions')
} }
return { return {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment