I'm implementing persons list inside my Meteor app. Every person has a lastName and firstName. I want to be able to search by full name or it's part. Of course search must be case insensitive. There will be about 500 persons, so I need pagination & I can't just filter the results on client side.
My general idea is to generate additional field fullName upon insert or update of a person:
fullName: lastName.toLowerCase() + ' ' + firstName.toLowerCase(),
And then just use it inside the find method:
PersonsCollection.find({ fullName: {$regex : searchString}, ... })
I'm pretty new to Meteor, Mongo and backend in general. I spent some time researching, but still confused. My questions are:
- Is there any real reasons against my implementation besides it's kinda ugly to create additional field?
- Is there a conventional way to do this in Meteor?