public static async Task <T> Update <T>(this T item) where T : IMongoModel { var collection = MongoTools.GetCollection <T>(); await collection.ReplaceOneAsync(a => a.Id == item.Id, item); return(item); }
public static T UpdateSync <T>(this T item) where T : IMongoModel { var collection = MongoTools.GetCollection <T>(); collection.ReplaceOne(a => a.Id == item.Id, item); return(item); }
public static async Task <T> Insert <T>(this T item) where T : IMongoModel { var collection = MongoTools.GetCollection <T>(); await collection.InsertOneAsync(item); return(item); }
public static T InsertSync <T>(this T item) where T : IMongoModel { var collection = MongoTools.GetCollection <T>(); collection.InsertOne(item); return(item); }
public static T Update <T>(this T item) where T : IMongoModel { var collection = MongoTools.GetCollection <T>(); collection.Save(item); return(item); }
public static async Task Delete <T>(this T item) where T : IMongoModel { var collection = MongoTools.GetCollection <T>(); var oid = item.Id; await collection.DeleteOneAsync(a => a.Id == oid); }
public static async Task Delete <T>(this string id) where T : IMongoModel { var collection = MongoTools.GetCollection <T>(); var oid = new ObjectId(id); await collection.DeleteOneAsync(a => a.Id == oid); }
public static void Delete <T>(this T item) where T : IMongoModel { var collection = MongoTools.GetCollection <T>(); collection.Remove(Query.EQ("_id", item.Id)); }
public static void Delete <T>(this string id) where T : IMongoModel { var collection = MongoTools.GetCollection <T>(); collection.Remove(Query.EQ("_id", ObjectId.Parse(id))); }