Handle search user with bookshelf

This commit is contained in:
cyril lopez 2017-11-29 16:24:11 +01:00
parent b4a6336f14
commit 6596e42e0b
2 changed files with 10 additions and 1 deletions

View File

@ -238,5 +238,15 @@ module.exports = {
// Resolve silently.
return Promise.resolve();
}
},
search: async function (params) {
return this
.query(function(qb) {
qb
.where('username', 'LIKE', `%${params.id}%`)
.orWhere('email', 'LIKE', `%${params.id}%`);
})
.fetchAll();
}
};

View File

@ -110,7 +110,6 @@ module.exports = {
searchUsers: async (ctx) => {
const data = await strapi.query('user', 'users-permissions').search(ctx.params);
return ctx.send(data);
},