I'm looking to implement a user search on my MongoDB database with Mongoose, it has a table of users with these fields:
- name (full name not unique)
- username (unique)
- there are other fields like email, dateCreated, etc. of course
I know how to do a search on or the other (only match username or only match name), but is it possible to implement search by both fields (match username or name)
E.g.
| Users | Username | |--------------|----------| | Will Riker | riker01 | | Bill Reilly | riker02 | | Daniel Riker | dan001 | | James dean | dean001 | And if I query on riker, it would return riker01, riker 02 and dan001
没有评论:
发表评论