nicolaslopezj / roles

The most advanced roles package for meteor
MIT License
87 stars 13 forks source link

'undefined' list of users after applying filter to roles #14

Closed ashishapy closed 8 years ago

ashishapy commented 8 years ago

After updating nicolaslopezj:roles 2.0.4 orionjs:relationships 1.7.0 and others

below code is also returns list of user (as 'undefined') having 'default' user role.

assignedTo: orion.attribute('users', {
            label: 'Assigned To',
            optional: true,
            autoform: {
                afFormGroup: {
                    'formgroup-class': 'col-md-12'
                }
            }
        }, {
                publicationName: 'Activity assgined to',
                additionalFields: ['roles'],
                filter: function () {
                    return { roles: { $ne: 'default' } } // // or { roles: 'contributors' }; 
                }
            })```
nicolaslopezj commented 8 years ago

Maybe the filter is not correct, try:

{ $or: [{ roles: { $ne: 'default' } }, { roles: { $exists: true } }] }
ashishapy commented 8 years ago

Thanks @nicolaslopezj . I tried $and as below & it worked. { $and: [{ roles: { $ne: 'default' } }, { roles: { $exists: true } }] }

But still I don't understand if I have only 7 users in db & all user has role assigned. so this { roles: { $ne: 'default' } } should work. Two were having role as 'default'. Only those users were coming as 'undefined' in the list .

Sometimes I see some values like 'Loading...' as well. Not sure but seems some bug.

nicolaslopezj commented 8 years ago

You can try to debug the query in the console, like this

Meteor.users.find({ roles: { $ne: 'default' } }).fetch()