Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Jun 17 14:06
    braydie commented #860
  • Jun 17 14:05
    braydie commented #860
  • Jun 16 19:22
    Evgentus0 commented #2019
  • Jun 16 19:22
    Evgentus0 closed #2019
  • Jun 16 19:22
    Evgentus0 commented #2019
  • Jun 16 16:36
    edencloud edited #2020
  • Jun 16 16:33
    edencloud labeled #2020
  • Jun 16 16:33
    edencloud opened #2020
  • Jun 16 11:29
    Evgentus0 opened #2019
  • Jun 16 11:29
    Evgentus0 labeled #2019
  • Jun 16 08:22
    akashchopra commented #2010
  • Jun 14 11:07
    quiary labeled #2018
  • Jun 14 11:07
    quiary opened #2018
  • Jun 14 10:53
    quiary commented #2016
  • Jun 14 09:44
    laurentiucocanu edited #2017
  • Jun 14 09:44
    laurentiucocanu edited #2017
  • Jun 14 09:43
    laurentiucocanu edited #2017
  • Jun 14 09:42
    laurentiucocanu labeled #2017
  • Jun 14 09:42
    laurentiucocanu opened #2017
  • Jun 13 03:07
    kingketo closed #2014
Torben Stallknecht
It might be, that my Googling and reading abilities are crap, but I have been unable to find the answer. What, if any, limit is there to the database. I get that Documents are 1MB(16MB in newer versions?). There is a limit of 8000 bytes for collection names, which in essens limits the amount of collections. So, let's say I have 1 collection in my database. How many 1 MB documents can it store?
Leonardo Nascimento
@stallemanden There's no limit for number of documents in a collection.
Hello. My TimeSpan? store as {"$numberLong":"600000000"}, but when i try deserialize them i get exception: cant cast long to TimeSpan. But if i use non-nullable TimeSpan all is ok. What am I doing wrong?
Leonardo Nascimento
@SKProCH_gitlab What version of LiteDB are you using?

Is it possible to use the following expression with LiteDB?

return maintenanceAssetCollection.UpdateMany(_ =>
            new MaintainableAssetEntity()
                AttributeDatumEntities = new List<IAttributeDatumEntity>(),
                Id = _.Id,
                LocationEntity = _.LocationEntity,
                NetworkId = _.NetworkId
            _ => _.NetworkId == networkId);

I keep getting a runtime NotSupported exception. When I change the list assignment to null it works.

Ah, I changed the code to this and it seemed to work:

return maintenanceAssetCollection.UpdateMany(_ =>
            new MaintainableAssetEntity()
                AttributeDatumEntities = new List<IAttributeDatumEntity>() { },
                Id = _.Id,
                LocationEntity = _.LocationEntity,
                NetworkId = _.NetworkId
            _ => _.NetworkId == networkId);

Note the curly brackets in the new list expression are the change.

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!