Search results on nested fields (within relations) in Sails.js (waterline)

Viewed 275

I'm using Sails.js (waterline orm), to make an API

What I need and couldn't accomplish is filter results from a table (model), searching in all fields including nested ones:

I.e.:


GET /users/?filter=admin

>>> [{ id: 1, email: 'homer@example.com', role: 'admin' }, { id: 3, email: 'lisa@example.com', role: 'admin' }]


GET /users/?filter=homer

>>> [{ id: 1, email: 'homer@example.com', role: 'admin' }]


models/Users.js

{
    attributes: {
        email: {
            type: 'string'
        },

        role: {
            model: 'Roles'
        }
    }
}

models/Roles.js

{
    attributes: {
        role: {
            type: 'string'
        }
    }
}
1 Answers
Related