How to do case insensitive DB search?


I want to make a server-side method that will allow me to check if a user already exists in db.users, so I’ve made this:

  userExists: (username) ->
    check username, String

    console.log Meteor.users.find({username: username}).fetch()
    return { exists: true }

Obviously this is just a straight case-sensitive search. How do I look up a username regardless of case?


Sheesh. Always right after I post! Typical. Here’s the solution:

    x = Meteor.users.find
        $regex: "^#{username}$", $options: 'i'
    console.log x.fetch()


happens to me too all the time lols.