1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-26 12:55:17 +01:00

just type mapping for json docs

This commit is contained in:
Kyle Spearrin 2020-01-10 18:54:44 -05:00
parent d653629e79
commit 5bb440563f
4 changed files with 30 additions and 4 deletions

View File

@ -7,6 +7,8 @@ namespace Bit.Core.Models.EntityFramework
{
private JsonDocument _dataJson;
private JsonDocument _attachmentsJson;
private JsonDocument _favoritesJson;
private JsonDocument _foldersJson;
public User User { get; set; }
public Organization Organization { get; set; }
@ -16,7 +18,7 @@ namespace Bit.Core.Models.EntityFramework
get => _dataJson;
set
{
Data = value.ToString();
Data = value?.ToString();
_dataJson = value;
}
}
@ -26,10 +28,30 @@ namespace Bit.Core.Models.EntityFramework
get => _attachmentsJson;
set
{
Attachments = value.ToString();
Attachments = value?.ToString();
_attachmentsJson = value;
}
}
[IgnoreMap]
public JsonDocument FavoritesJson
{
get => _favoritesJson;
set
{
Favorites = value?.ToString();
_favoritesJson = value;
}
}
[IgnoreMap]
public JsonDocument FoldersJson
{
get => _foldersJson;
set
{
Folders = value?.ToString();
_foldersJson = value;
}
}
}
public class CipherMapperProfile : Profile

View File

@ -16,7 +16,7 @@ namespace Bit.Core.Models.EntityFramework
get => _twoFactorProvidersJson;
set
{
TwoFactorProviders = value.ToString();
TwoFactorProviders = value?.ToString();
_twoFactorProvidersJson = value;
}
}

View File

@ -16,7 +16,7 @@ namespace Bit.Core.Models.EntityFramework
get => _twoFactorProvidersJson;
set
{
TwoFactorProviders = value.ToString();
TwoFactorProviders = value?.ToString();
_twoFactorProvidersJson = value;
}
}

View File

@ -20,6 +20,10 @@ namespace Bit.Core.Repositories.EntityFramework
builder.Entity<Cipher>().Property(e => e.DataJson).HasColumnName("Data");
builder.Entity<Cipher>().Ignore(e => e.Attachments);
builder.Entity<Cipher>().Property(e => e.AttachmentsJson).HasColumnName("Attachments");
builder.Entity<Cipher>().Ignore(e => e.Favorites);
builder.Entity<Cipher>().Property(e => e.FavoritesJson).HasColumnName("Favorites");
builder.Entity<Cipher>().Ignore(e => e.Folders);
builder.Entity<Cipher>().Property(e => e.FoldersJson).HasColumnName("Folders");
builder.Entity<User>().Ignore(e => e.TwoFactorProviders);
builder.Entity<User>().Property(e => e.TwoFactorProvidersJson).HasColumnName("TwoFactorProviders");