Filter user input

Lets say that the user has made an account and is now stored in mongodb. When the user is taking some action i want mongodb to filter out the username input. So that it could actually change something for that specific document, in other words: “for the user that has logged in.” How would i do something like that?

So for example:
const {text} = req.body;
var input = text
const filter = { charactername: text};

But when i do this mongodb won’t be able to find the document.

So the text would be the username which the user has already specified in the beginning, so it
would be the users input. But now i want to do this without hardcoding it.