sync: minor refactors

This commit is contained in:
Abdullah Atta
2026-01-01 10:35:35 +05:00
parent da8df8973c
commit 8908b8c6ed
3 changed files with 3 additions and 6 deletions

View File

@@ -91,11 +91,7 @@ namespace Notesnook.API.Repositories
public void DeleteByUserId(string userId)
{
var filter = Builders<SyncItem>.Filter.Eq("UserId", userId);
var writes = new List<WriteModel<SyncItem>>
{
new DeleteManyModel<SyncItem>(filter)
};
dbContext.AddCommand((handle, ct) => Collection.BulkWriteAsync(handle, writes, options: null, ct));
dbContext.AddCommand((handle, ct) => Collection.DeleteManyAsync(handle, filter, null, ct));
}
public void Upsert(SyncItem item, string userId, long dateSynced)

View File

@@ -81,7 +81,7 @@ namespace Notesnook.API.Services
if (chunk != null)
{
var update = Builders<DeviceIdsChunk>.Update.PushEach(x => x.Ids, ids.Select(i => i.ToString()));
var update = Builders<DeviceIdsChunk>.Update.AddToSetEach(x => x.Ids, ids.Select(i => i.ToString()));
await repositories.DeviceIdsChunks.Collection.UpdateOneAsync(
Builders<DeviceIdsChunk>.Filter.Eq(x => x.Id, chunk.Id),
update

View File

@@ -182,6 +182,7 @@ namespace Notesnook.API.Services
public async Task DeleteUserAsync(string userId)
{
logger.LogInformation("Deleting user {UserId}", userId);
var cc = new CancellationTokenSource();
Repositories.Notes.DeleteByUserId(userId);