To start with, what you have done with the code above is create a document with an id of the string 'info'. Only one unique id could exist which would make querying unnecessary. In order to do a string search it would also be best to split the string into an array. II assume what you want to do is something like:
let info = "some string to go in document"
info = info.split(" ");
// Add a new document with a generated id.
firebase.firestore().collection("usernames").add({
info: info
})
.catch((error) => {
console.error("Error adding document: ", error);
});
Then you can query all documents in the collection to see if the info array contains a certain string word:
let check = "string"
firebase.firestore().collection("usernames").where('info', 'array-contains', check).get().then(function(querySnapshot) {
querySnapshot.forEach(function(doc) {
console.log(doc.id, " => ", doc.data());
});
});
Hope this is helpful, its a difficult problem