lbnascimento on master
Revert "Fixed member mapping fo… (compare)
Argument 1: cannot convert from 'FileHashEntry' to 'LiteDB.BsonValue'
Assembly LiteDB, Version=18.104.22.168
idvariable when calling
hashes.DeleteMany(h => h.Hash == hash)
Hashis an unique identifier of every file (which I believe it is), you could use our fluent mapper to set it as the Id field:
BsonMapper.Global.Entity<FileHashEntry>().Id(x => x.Hash)
Hi, I have a couple of questions, as I couldn't find a direct answer in the docs.
1) Does LiteDB support multi-threading and do I need to pay attention to anything special when using it multi-threaded?
2) After getting a ILiteCollection with LiteDatabase.GetCollection(), there is the method ILiteCollection.Upsert(), I suppose it uses the ID to figure out whether it should be added or updated in the collection. There are Bulk operations for Insert & Update but not for Upsert. What would be a good way to handle this? I am using LiteDB as a save-file. Objects are only "written" to the Collection when explicitly saving, so I would have to track objects that already exist and objects that haven't been saved yet, and call BulUpdate on existing and BulkInsert on new ones, as calling Upsert in a loop over and over for each object might not be a good idea, right?
3) I am not exactly understanding the purpose for the .EnsureIndex() method. This is not what creates the ID values, correct? It's meant to speedup searching for entries in a collection via fields that were marked with .EnsureIndex(), or am I wrong?
Thanks for any answers in advance
ILiteDatabase.BeginTrans(), upserting your objects with a loop and calling
ILiteDatabase.Commit()after you're done. This will be a lot faster that inserting one object per transaction (which is the default behavior).
EnsureIndex()only once. This will index pre-existing objects and will also index anything that is inserted/updated in the collection in the future.