Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Sep 26 10:26
    jurasans commented #2232
  • Sep 22 13:22
    LazarQt commented #2221
  • Sep 22 06:55
    devmaestro1 edited #2241
  • Sep 22 05:23
    devmaestro1 edited #2241
  • Sep 22 05:22
    devmaestro1 edited #2241
  • Sep 22 04:57
    devmaestro1 edited #2241
  • Sep 22 04:23
    devmaestro1 edited #2241
  • Sep 22 04:23
    devmaestro1 labeled #2241
  • Sep 22 04:23
    devmaestro1 opened #2241
  • Sep 21 12:14
    gjvanvuuren commented #2221
  • Sep 21 02:02
    LazarQt commented #2221
  • Sep 20 14:26
    yisman commented #1790
  • Sep 20 14:26
    yisman commented #1790
  • Sep 20 14:26
    yisman commented #1790
  • Sep 19 06:47
    pjy612 commented #2238
  • Sep 19 06:44
    pjy612 commented #2238
  • Sep 17 03:00
    DragonXYZ closed #2240
  • Sep 17 02:59
    DragonXYZ commented #2240
  • Sep 16 22:17
    stephenhauck commented #2240
  • Sep 16 14:22
    500lb-Bench closed #2239
@agreentejada I have already restricted all inserts to transactions and/or InsertBulk operations, and the Global Atom Table still seems to grow and grow
@marhaako Yeah, I don't know too much about memory, our entries tend to be within 100k items a table.
@agreentejada Thanks for your feedback...
Hello. Just curious for the future. Are there any dev plans to move to .Net 6
Hello i will git a try to litedb but i have a question about le LiteDatabase object lifetime, should i use it has Singleton in my DI or has Transient ?
My database is opened with read-only mode. Why LiteDB.Engine.WalIndexService.TryCheckpoint() is called when I have only opened the database for reading and I have no committed transactions.
Is there any particular reason of adding the call in case database is opened for reading ?
As my thread that is reading from file is stuck at dispose call.
Ricardo Figueiredo
Hi all,
got same question as @hidemat - is it ready for .net 6 or planned migration?
Already understood it can be consumed as .net standard 2.. even so direct path to LTS .Net 6 would be nice.
Hi, I've recently run into an issue with sqlite on Android in the native implementation which we cannot replace. So I am looking into LiteDB as a replacement. Is it safe to say sqlite and litedb have similar use cases
or is there anything I should be aware of
Nicolai Linde
Is there an attribute I can mark my Guid ID's with so I can name them "CustomerId" instead of "Id" ?
Aha, [BsonId]
Damien Doumer
Hi, does anyone know how to reduce Litedb's memory consumption ?
I'm using it in Xamarin Forms
I am having this weird issue where SELECT $ FROM entries WHERE _id = "28669BD8DB6D8A5C711F8E7FD15DC6C8" returns nothing but `.FindById("28669BD8DB6D8A5C711F8E7FD15DC6C8") does return a document.
Damien Doumer
I'm having a this litedb error on Xamarin Android, The only time I close my litedb connection (call Dispose()) is when "Activity. Destroy" is called. But I get errors like: DiskReader.ReadStream (System.IO.Stream stream, System.Int64 position, LiteDB.BufferSlice buffer)
System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Stream has been closed'.
Can someone please help ? is there a trick somewhere ?
Jin-Wook Chung
Hello, I left a question on SO as I had a question about LiteDB's connection mode. If you have time, I would appreciate it if you could look at my question.
Paramjit Singh
Hello All, Is LiteDB ready for DotNet Maui
I am using it on Android, given that it's fully managed code, I'd say 99% it's MAUI ready

Hello! I would like to select two field from my root document: RootProp and ChildProp (which is an array of objects), based on a condition:

SELECT $.RootProp, $.ChildProp[@.Name = 'ChildPropName'] FROM MyCollection WHERE COUNT($.ChildProp) > 0

My goal is to get only those results that have a populated ChildProp array (Where statement). However in the results I get also those records which do not contains any element on the ChildProp array. What am I missing? thanks


:point_up: Edit: Hello! I would like to select two field from my root document: RootProp and ChildProp (which is an array of objects), based on a condition:

SELECT $.RootProp, $.ChildProp[@.Name = 'ChildPropName'] FROM MyCollection WHERE COUNT($.ChildProp) > 0

My goal is to get only those results that have a populated ChildProp array (Where statement). However in the results I get also those records which do not contains any element on the ChildProp array. What am I missing? thanks

Has anyone here used LiteDb for application state management?

Hello! I need help in updating a list in my User table:
i have a Table called User. The User has a List with Devices.
Now i changed my Device assembly and namespace and now i need to change the Type (_type) of my Devices.
I tried so many approaches but nothing did work and im out of ideas. The last command i tried was:
'''UPDATE User SET Devices = Devices[]._type = 'DeviceSet.Mobile.Models.BleDevice, DeviceSet' ''' which gave me following Error:
Left expression `MAP($.Devices[
]=>@._type)` returns more than one result. Try use ANY or ALL before operant.

I'm looking forward to any help!

JeeShen Lee

Hello, I recently changed a field's data type from int to string.

After the changes, I'm getting "Casting Exception" when I try to read the records.

I did some reading and notice that I need to manage the new schema using DatabaseVersion. In order to change the schema, I need to perform the migration to the existing database. Is this the right way to do? Any other idea?

JeeShen Lee

I went ahead to implement the migration to change the data type by resaving the BSONValue.

After that, I increment the database version to 1.

Now, how do I mark a newly created database to version 1 so it won't have to go through the migration (migration is meant for existing database).

Rafał Piotrowski
Hi, can I force litedb to flush data to disk? My problem is that after update and shortly after when I read the data is not reflecting the changes made by update!
Rafał Piotrowski
BTW. I am calling Checkpoint and I have also set CheckpointSize to 0 to manually call Checkpoint.
ajay kishore
I have dotnetnuke db file, can i open that in litedb. how to view other db files in litedb with different extensions(not the .db)
Tim Moore
Hi, what does this error mean? Google turned up only one result and it's in Chinese!
      System.Exception: LiteDB ENSURE: get only index below highest index
         at LiteDB.Constants.ENSURE(Boolean conditional, String message)
         at LiteDB.Engine.BasePage.Get(Byte index)
         at LiteDB.Engine.IndexService.DeleteAll(PageAddress pkAddress)
         at LiteDB.Engine.LiteEngine.<>c__DisplayClass3_0.<Delete>b__0(TransactionService transaction)
         at LiteDB.Engine.LiteEngine.AutoTransaction[T](Func`2 fn)
         at LiteDB.Engine.LiteEngine.Delete(String collection, IEnumerable`1 ids)
         at LiteDB.SharedEngine.Delete(String collection, IEnumerable`1 ids)
         at LiteDB.LiteCollection`1.Delete(BsonValue id)
Tim Moore

I know LiteDB is probably not ideal for this, but is there any advice on deployment on a active/standby cluster?

Due to customer requirements project I'm working on has been deployed this way and the .db files are replicated to the standby. Failover occurs and in theory it picks up on the standby.

It appears to work in testing but there's concern that it may not be robust and have reports of some issues that haven't been reproduced (and no errors logged). May be totally unrelated, but want to check if anyone has deployed on such a cluster set up.

Long term the aim is to implement Mongo DB or similar for this.

Alex Sinitsky
Hey guys, getting an exception while trying to do thebase.Insert(rec) - "this page should be in slot #0". Interestingly, the exception isn't thrown in debug, and Insert actually works correctly. I've checked why does it throw and found out the slot is 1 instead of 0, thus ENSURE throws an exception. Does anybody know what might be the issue here?
Paramjit Singh
Hello all
I want to save ordered items by date in LiteDb like this
IEnumerable<Destination> orderedList = destinations.OrderBy(d => d.TripStartDate);
But when I access the Destinations in the app it is not in correct order by StartDate
Am I doing something wrong. Please help
Matthew Oh
1 reply
Shahab Ouraie

Hello everyone @/all
I'm new to whole this, so plz correct me if I'm wrong:
1- A poco class when inserts into DB known as a Document;
2- If a poco class contains an object property of another poco class, this is a SubDocument;

1- Does $ symbol refers to the main poco class/Document when used in LINQ-expressions?
2- Whats different between SELECT $ from students and SELECT * from students (Basically * and $)?
3- Whats is and the difference between Collection and Document ?

tnx in advance; Couldnt find out through docs...

ariana strangelove
Hi :)
oh nvm, i can read the source
Scott Wolf
Is there any method to run a repair on a database. I am getting the following exception when trying to open a file.
System.Exception: LiteDB ENSURE: ReadFull must read PAGE_SIZE bytes [4096]
   at LiteDB.Constants.ENSURE(Boolean conditional, String message)
   at LiteDB.Engine.DiskService.ReadFull(FileOrigin origin)+MoveNext()
   at LiteDB.Engine.WalIndexService.<>c__DisplayClass19_0.<<CheckpointInternal>g__source|0>d.MoveNext()
   at LiteDB.Engine.DiskService.Write(IEnumerable`1 pages, FileOrigin origin)
   at LiteDB.Engine.WalIndexService.CheckpointInternal()
   at LiteDB.Engine.WalIndexService.TryCheckpoint()
   at LiteDB.Engine.LiteEngine.Dispose(Boolean disposing)
   at LiteDB.Engine.LiteEngine..ctor(EngineSettings settings)
Ilya Popov
@wolfson292 LiteDB Studio?
Hi guys, could you help. How can i do postgres-like "DO NOTHING" for Upsert on needed property?
Sébastien Duterte
Hello guys !
I need some help with an error with a "LiteDB ENSURE exception : page type must be collection page".
Do you know how this error occurs ? Is it possible to get this error when the database is killed brutally (without dispose, for exemple) ?

I am looking at integrating this with an existing project, so we already have data models etc but we already have a Guid based Id field, is there a way to hint/tell Lite DB to just use that field to be the id .

Not fussed if it duplicates the custom Id into _id or some other mechanism, I just need to be able to query on the Guid not the BsonValue based Id, although I appreciate I may externally use a Guid in my data access layer but internally it may have to just make a BsonValue on the fly or something...

Anyway any advice on this would be great as I assume its a common use case, just couildnt find much in the docs around it


Also I have a query around dynamic style types, i.e I have a class with an interface property so when deserializing its not clear what C# type it is.

When I was using JSON.Net I had a custom JsonConverter which handled that part, but im not entirely sure here how to mimic that with LiteDB, historically all the data used to be pumped out to raw json files using JSON.Net so generally it seems a good fit for just moving each json file to be its own collection, but not quite sure how to work around that bit

I have put a question about this on stack overflow so if anyone does read this and knows please put the answer in there https://stackoverflow.com/questions/73611168/any-way-to-mimic-jsonconverter-style-serializing-deserializing-of-complex-object
For now im just going to introduce an intermediate JSON layer in our repositories which converts them into BsonDocuments and hope for the best :D

Dim Result = m_Col.Find(Function(x) x.Name.StartsWith("F")).ToList
--> If an entry starting with "F" is found, I get this exception:

System.NullReferenceException: "The object reference was not set to an object instance.

--> If no entry starting with "F" is found, I get an empty list "Result" (LiteDB.LiteCollection(Of T)

Where is my problem? Thanks for quick help!

Sorry: list "Result" (List(Of T))