public static PlusPlusThing GetThing(string thing) { var filter = Builders<PlusPlusThing>.Filter.Eq<string>("_id", thing); PlusPlusThing plusPlusThing = Client.ThingCollection.Find(filter).FirstOrDefault(); if (plusPlusThing == null) { plusPlusThing = new PlusPlusThing(); plusPlusThing.Id = thing; plusPlusThing.Score = 0; SaveThing(plusPlusThing); } return plusPlusThing; }
private static void SaveThing(PlusPlusThing thing) { Client.ThingCollection.ReplaceOne(Builders<PlusPlusThing>.Filter.Eq<string>("_id", thing.Id), thing, new UpdateOptions { IsUpsert = true }); }