Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created September 29, 2017 17:25
Show Gist options
  • Save NMZivkovic/d58254a307643aa35863738200667ec2 to your computer and use it in GitHub Desktop.
Save NMZivkovic/d58254a307643aa35863738200667ec2 to your computer and use it in GitHub Desktop.
public async Task<bool> DeleteUserById(ObjectId id)
{
var filter = Builders<User>.Filter.Eq("_id", id);
var result = await _usersCollection.DeleteOneAsync(filter);
return result.DeletedCount != 0;
}
public async Task<long> DeleteAllUsers()
{
var filter = new BsonDocument();
var result = await _usersCollection.DeleteManyAsync(filter);
return result.DeletedCount;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment