Added getSpellsFromUser() method
This commit is contained in:
@@ -30,7 +30,7 @@ class SpellRepository {
|
||||
if (cost) { query.where({ 'cost' : cost }) }
|
||||
if (ritual) { query.where({ 'is_ritual' : ritual }) }
|
||||
|
||||
query.fetchAll({ withRelated: ['schools.meta_schools', 'variables', 'ingredients'] })
|
||||
query.fetchAll({ withRelated: [ 'schools.meta_schools', 'variables', 'ingredients', 'author' ] })
|
||||
.then(v => {
|
||||
resolve(v.toJSON({ omitPivot: true }))
|
||||
})
|
||||
@@ -56,7 +56,7 @@ class SpellRepository {
|
||||
if (cost) { query.where({ 'cost' : cost }) }
|
||||
if (ritual) { query.where({ 'is_ritual' : ritual }) }
|
||||
|
||||
query.fetchAll({ withRelated: ['schools.meta_schools', 'variables', 'ingredients'] })
|
||||
query.fetchAll({ withRelated: [ 'schools.meta_schools', 'variables', 'ingredients', 'author' ] })
|
||||
.then(v => {
|
||||
resolve(v.toJSON({ omitPivot: true }));
|
||||
})
|
||||
@@ -77,7 +77,7 @@ class SpellRepository {
|
||||
.fetchPage({
|
||||
pageSize: 20,
|
||||
page: page,
|
||||
withRelated: ['schools.meta_schools', 'variables', 'ingredients'],
|
||||
withRelated: [ 'schools.meta_schools', 'variables', 'ingredients', 'author' ],
|
||||
})
|
||||
.then(v => {
|
||||
resolve(v.toJSON({ omitPivot: true }))
|
||||
@@ -96,7 +96,7 @@ class SpellRepository {
|
||||
return new Promise((resolve, reject) => {
|
||||
new model()
|
||||
.where({ 'id' : id })
|
||||
.fetch({ withRelated: ['schools.meta_schools', 'variables', 'ingredients']})
|
||||
.fetch({ withRelated: [ 'schools.meta_schools', 'variables', 'ingredients', 'author' ]})
|
||||
.then(v => {
|
||||
resolve(v.toJSON({ omitPivot: true }))
|
||||
})
|
||||
@@ -170,7 +170,7 @@ class SpellRepository {
|
||||
})
|
||||
})
|
||||
.then(v => {
|
||||
return v.load(['schools.meta_schools', 'variables', 'ingredients'])
|
||||
return v.load([ 'schools.meta_schools', 'variables', 'ingredients', 'author' ])
|
||||
})
|
||||
.then(v => {
|
||||
resolve(this.getOne(v.id))
|
||||
@@ -206,7 +206,7 @@ class SpellRepository {
|
||||
});
|
||||
} else {
|
||||
new model({id: id})
|
||||
.fetch({require: true, withRelated: ['schools.meta_schools', 'variables', 'ingredients']})
|
||||
.fetch({require: true, withRelated: [ 'schools.meta_schools', 'variables', 'ingredients', 'author' ]})
|
||||
.then(v => {
|
||||
bookshelf.transaction(t => {
|
||||
return v.save({
|
||||
@@ -269,7 +269,7 @@ class SpellRepository {
|
||||
})
|
||||
})
|
||||
.then(v => {
|
||||
return v.load(['schools.meta_schools', 'variables', 'ingredients']);
|
||||
return v.load([ 'schools.meta_schools', 'variables', 'ingredients', 'author' ]);
|
||||
})
|
||||
.then(v => {
|
||||
resolve(this.getOne(v.id));
|
||||
@@ -297,7 +297,7 @@ class SpellRepository {
|
||||
return new Promise((resolve, reject) => {
|
||||
new model()
|
||||
.where({ 'id' : id })
|
||||
.fetch({require: true, withRelated: ['schools.meta_schools', 'variables', 'ingredients']})
|
||||
.fetch({require: true, withRelated: [ 'schools.meta_schools', 'variables', 'ingredients', 'author' ]})
|
||||
.then(v => {
|
||||
v.schools().detach();
|
||||
v.variables().detach();
|
||||
|
||||
@@ -63,7 +63,7 @@ class UserRepository {
|
||||
return new Promise((resolve, reject) => {
|
||||
new model()
|
||||
.where({ 'mail': mail })
|
||||
.fetch()
|
||||
.fetch({ withRelated: [ 'role' ] })
|
||||
.then(v => {
|
||||
resolve(v.toJSON({ omitPivot: true, visibility: !full }));
|
||||
})
|
||||
@@ -72,7 +72,24 @@ class UserRepository {
|
||||
"message": "L'utilisateur avec cet email n'a pas été trouvé.",
|
||||
"code": 404,
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
getSpellsFromOne(uuid) {
|
||||
return new Promise((resolve, reject) => {
|
||||
new model()
|
||||
.where({ 'uuid': uuid })
|
||||
.fetch({ withRelated: [ 'role', 'spells.schools.meta_schools', 'spells.variables', 'spells.ingredients' ] })
|
||||
.then(v => {
|
||||
resolve(v.toJSON({ omitPivot: true }));
|
||||
})
|
||||
.catch(() => {
|
||||
reject({
|
||||
"message": "Les sorts liés à cet utilisateur n'ont pas été trouvés.",
|
||||
"code": 404,
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user