I am starting with MongoDb on c#. At the end, I need function which simply checks if the user exists in DB -thats it. I am a complete beginner so naturally example right from MongoDb tutorial does not work here are examples:
public static async Task<List<User>> QueryDB(User u)
{
var collection = _database.GetCollection<User>("UserData");
var filter = Builders<User>.Filter.Eq("id", u.id);
var result = await collection.Find(filter).ToListAsync();
return result;
}
or
public static async Task<long> QueryDB(User u)
{
var collection = _database.GetCollection<User>("UserData");
var filter = Builders<User>.Filter.Eq("id", u.id);
var result = await collection.Find(filter).CountAsync();
return result;
}
What is wrong with these functions? Or how should I call them? Because now it throws a timeout. Can this be done without async/await? I think I don't need it