2 ways to do this:
With regular expression. MongoDB supports regular expression match. here's an example:
users.find({firstname: /Jo/}, function(err, doc) {...})
However, if you got a big collection, it's going to be slow. Because regular expression usually doesn't use index at all unless you have a fixed prefix like /^Jo/.
Or in some situations you may want to try the new feature, full text search: First of all, you need an text index:
db.users.ensureIndex( { firstname: "text" } );
Then use the $text operator:
db.users.find({ $text: { $search: "Jo"}});
The text search does not just look for exactly what you are searching. And in some situations it may not work the way you wanted.
The $text operator can search for words and phrases. The query matches on the complete stemmed words. For example, if a document field contains the word blueberry, a search on the term blue will not match the document.
More information, please refer to the document.