In LiteDB 5, what does the bool return value mean with Upsert on a LiteCollection? I can't find documentation saying what it does.
I'd normally assume false means it didn't apply changes, but on first call it inserts a document and returns true, and second call with document with same ID and different values, it updates the record but returns false.
I've got existing code that assumed true just meant success and if that's not the case I've got some bugs there. Although that was with LiteDB 4, and I'm migrating to 5.
public class CharacterTraits
{
[BsonId]
public int Index { get; set; }
public uint CharacterId { get; set; }
public uint TraitId { get; set; }
public SpoilerLevel SpoilerLevel { get; set; }
}
I then have a List<CharacterTraits> characterTraitsList = new List<CharacterTraits>();
with multiple elements in it. But when I run the following command (dbCharTraits.InsertBulk(CharacterTraitsList);
), I get the following error.
Hi! I've got a question about performance - I am using FindByOne
method on my collection, but it seems like it takes some to load the document from the database. Here's my F# implementation of GetById
repository
member this.GetById (id: string): 'a option =
let mapper = FSharpBsonMapper()
use db = new LiteDatabase(connectionString, mapper)
let collection = db.GetCollection<BsonDocument>(collectionName)
let queryResult = collection.FindById (BsonValue(id))
Option.fromBson queryResult
As I understood, _id
is indexed automatically so it should be rather fast, isn't it? My DB file on the disc has approx. 30MB.
I just want to understand what happens that it's slow :-) I would appreciate any help/clarification
\\
in position 7."}
I did find a workaround though. If I add a private constructor with no parameter it works... That way nobody can call that constructor from outside so my entity integrity is kept. However I feel a bit weird with that though... The real solution would be to create my own mappers that will map to a the LiteDB entity version of the entity and use those in my Repository. Like that I won't touch the object itself, that should be kept pure in its app context regardless its repository DB type.
Any thoughts? Am I missing something that is already built-in?