Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • 18:36
    lbnascimento commented #1759
  • 14:25
    tomandr commented #1759
  • 13:40
    lbnascimento commented #1944
  • 13:19
    lbnascimento commented #1943
  • 08:49
    Garon147 commented #1942
  • 08:27
    Garon147 commented #1942
  • Feb 25 21:13
    sigmarsson closed #1946
  • Feb 25 21:13
    sigmarsson commented #1946
  • Feb 25 19:27
    nabeelio commented #1940
  • Feb 25 14:12
    lbnascimento commented #1940
  • Feb 25 13:53
    nabeelio commented #1940
  • Feb 25 13:18
    lbnascimento commented #1946
  • Feb 25 13:13
    mbdavid commented #1940
  • Feb 25 12:49
    nabeelio commented #1940
  • Feb 25 12:48
    nabeelio commented #1940
  • Feb 25 11:50
    mbdavid commented #1940
  • Feb 25 11:35
    sigmarsson opened #1946
  • Feb 25 11:35
    sigmarsson labeled #1946
  • Feb 25 09:26
    ruslanmogilevskiy closed #1945
  • Feb 25 09:26
    ruslanmogilevskiy commented #1945
Osama Al Banna

Hi, I can not find any way to use expressions and functions: https://www.litedb.org/api/functions/ https://www.litedb.org/docs/expressions/
how can I do that?
suppose I have a collection Called
FinancialContractCollection contains Contracts

 public class FinancialContract : ReactiveObject, IHotHostReloaded<FinancialContract>
        [BsonId] public ObjectId Id { get; set; }

        public string PersonName { get; set; }
        public string PersonIdNumber { get; set; }
        public DateTime StartDate { get; set; }

How can I get the recent Contract with depends on StartDate by using Functions | Expressions

The problem is i can not find anything in the documentation descripe how to use it, the only example is with indices

And take this example from expressions page

    SELECT { upper_titles: ARRAY(UPPER($.Books[*].Title)) } WHERE $.Name LIKE "John%"

How can i execute this from c# ??

Please Helpe me.

Mike Photo Vintage
Operation could destabilize the runtime
When I create the db or insert data I get this error: "Operation could destabilize the runtime".
WebAPi hosted, I have write permissions, a test file is written regularly.

Hi everyone

I'm trying to use LiteDB (net45) in Unity 2019 targeting an ARM device. The sample application to perform CRUD operations works fine in the editor but in the device I'm getting this exception:

System.NotSupportedException: Invalid BsonExpression when converted from Linq expression: x => x.Name - `$.Name` ---> System.TypeInitializationException: The type initializer for 'LiteDB.BsonExpression' threw an exception. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: method

I did some googling and found a stack overflow question asking about this, in which the one answer states that this could be due to missing dependencies. However, I am using the .NETFramework 4.5 DLL which according to the NuGet page does not have any dependencies.

Has anyone faced this issue? If so can someone let me know how I can address this?

i need a api key !!
My log file grows indefinitely it seems on Azure
what a weird issue
Tim Moore

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.

Hello, I'd like to ask what the return value of the rebuild() function is supposed to represent?
Hey there, dumb question - is there a simple way to serialize my entire database into a JSON string?

Sometimes, with LiteDb 5, I will need to trigger Upsert twice for it to be saved into the database. I can't replicate this problem, sometime it works, sometime it wont'.

Can this be a code racing issues?

Any idea why this is happening?

Najem Azdufal (Nesh)
Hello togehter, i have updated an older Application from Version 3 to 5. My Idea was to speedup some queries by using projection. What i found out, that it takes more time to receive a projected Result than getting the whole document. ist this right?
How do I query an index for unique values?
I'm having an issue trying to get the autoID mapping working in litedb 5.0.9
public class CharacterTraits
        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.
""Cannot insert duplicate key in unique index '_id'. The duplicate value is '1'.""
Damian PÅ‚aza

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

Hi All, I need a help. I have updated LiteDB package in one of my projects from 0.9 to the latest version. All is ok but error:
var files = db.FileStorage.Find(strResource); // <----------------- no FileStorage
foreach (var fi in files)
var stream = fi.OpenRead();
return stream;
How to fix it ?
Another question: after upgrade nuget from 0.9 to the latest one my app cannot open the existing database
Message = "File is not a valid LiteDB database format or contains a invalid password."
How to fix it?
Torben Stallknecht
I am not sure, but I would think, that you need to upgrade the DB step-by-step.
I assume, that the upgrade to v5 requires a certain version to be able to upgrade.
You are right, but it is not possible to upgrade v 0.9 to any up version. I have tried to use "upgrade=true" in connection string - does not work. LiteDB studio does not understand this db format too.
Torben Stallknecht
I had a look at the version release notes. It states for version 1.0.0: To prepare LiteDB to future, version 1.x break compatibility with 0.x. Small external changes, but very important to make a better source structure:
So i guess the only way is to write some sort of conversion program for your data, to get it to a newer version.
Yes, it is one way ....
Another problem using the v5 in comparison with 0.9.
But in the v5 in gives me exception:
{"Unexpected token \\ in position 7."}
How to find this key in the db?
Torben Stallknecht
@win32nipuh I must admit, I am not that sure about it, but i suspect, that the reason your code is not working as intended is, the big change mentioned before. I have not worked with earlier versions. Anyway, from what I can see, the reason for the error, is the "\" in your string.
@stallemanden I see, you mean: in my case need to replace all '\' with '/' in the db and then search strResource2 = @"monitor/index.html";
@lbnascimento and team can we get an updated NuGet release? It has been 4 months since 5.0.9 and many bugs fixes since then. Can you push a fresh nuget update soon? Thx!
hi, how do i have to formulate an expression in LiteDB Studio with DateTime : SELECT $ FROM Collections WHERE Status = 'Imported' AND Created > '2020-12-07T00:00:00'; does not work -- Created is DateTime but query shows all documents
can anyone help me regarding my github query regarding LiteDB
I am trying to find where LiteDB stores my database in C# Visual Studio. any help? I have searched the entire C: Drive and am trying to use it to populate a DataGridView in WinForms. I have been using CSV files but need more functionality to do updates and formulas. Thanks, Derek
Torben Stallknecht
@derekone if no specific path is given, I would assume together with you application executable.
That's what I see any way.
Hello everyone. What is the maximum size that the database can reach? Is there some limitation of the db file size? Thanks in advance!
Torben Stallknecht
@angelv048 I asked more or less the same question back in Oktober. In essens, what I got from the answer was, that there is no limit. The only limit is the Document size of 1 MB
Hello everyone, I'm working with the LiteDB nuget package, loving it so far
Quick question: Is it better to use a single LiteDB instance for multiple operations, or get a new object everytime? Right now, I've created a singleton that manages the creation of all my LiteDBs, and I don't dispose of them afterward
Hello, I'm looking to use a serverless db for my winform applicaiton and was about to choose SQLite and came upon this awesome library and I'm considering to use it.
However, I have few issues like my objects use parameter constructors and I know by default the mapper doesn't handle that. I searched and saw that there are some solutions but the examples are super simple and I was wondering if anyone knows about a real project at everyone's disposal handling that case. Thanks

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?

Julien Amsellem
Hello, I wonder if it's safe to read a collection at the same time than another collection is being written to (the file is opened in shared mode) ?