mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 21:13:28 -07:00
moved log to object db.
This commit is contained in:
parent
71dcd623f7
commit
b3c6db5997
21 changed files with 157 additions and 321 deletions
|
@ -6,6 +6,7 @@ namespace NzbDrone.Core.Datastore
|
|||
public interface IBasicRepository<TModel>
|
||||
{
|
||||
IEnumerable<TModel> All();
|
||||
int Count();
|
||||
TModel Get(int id);
|
||||
TModel Insert(TModel model);
|
||||
TModel Update(TModel model);
|
||||
|
@ -13,6 +14,7 @@ namespace NzbDrone.Core.Datastore
|
|||
void Delete(int id);
|
||||
IList<TModel> InsertMany(IList<TModel> model);
|
||||
IList<TModel> UpdateMany(IList<TModel> model);
|
||||
void Purge();
|
||||
}
|
||||
|
||||
public class BasicRepository<TModel> : IBasicRepository<TModel> where TModel : ModelBase, new()
|
||||
|
@ -31,6 +33,11 @@ namespace NzbDrone.Core.Datastore
|
|||
return Queryable.ToList();
|
||||
}
|
||||
|
||||
public int Count()
|
||||
{
|
||||
return Queryable.Count();
|
||||
}
|
||||
|
||||
public TModel Get(int id)
|
||||
{
|
||||
return Queryable.Single(c => c.OID == id);
|
||||
|
@ -58,11 +65,11 @@ namespace NzbDrone.Core.Datastore
|
|||
|
||||
public TModel Upsert(TModel model)
|
||||
{
|
||||
if(model.OID == 0)
|
||||
{
|
||||
return ObjectDatabase.Insert(model);
|
||||
}
|
||||
return ObjectDatabase.Update(model);
|
||||
if (model.OID == 0)
|
||||
{
|
||||
return ObjectDatabase.Insert(model);
|
||||
}
|
||||
return ObjectDatabase.Update(model);
|
||||
}
|
||||
|
||||
public void Delete(int id)
|
||||
|
@ -70,5 +77,18 @@ namespace NzbDrone.Core.Datastore
|
|||
var itemToDelete = Get(id);
|
||||
ObjectDatabase.Delete(itemToDelete);
|
||||
}
|
||||
|
||||
public void DeleteMany(IEnumerable<int> ids)
|
||||
{
|
||||
foreach (var id in ids)
|
||||
{
|
||||
Delete(id);
|
||||
}
|
||||
}
|
||||
|
||||
public void Purge()
|
||||
{
|
||||
DeleteMany(Queryable.Select(c => c.OID));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue