Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 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
knuxbbs
@knuxbbs:matrix.org
[m]
Look at H2, they have something like this
And .NET have Blazor WebAssembly, who fits perfectly
Tim Moore
@tjmoore

Hi, can anyone explain how ITypeNameBinder is used?

It's referenced here and something got merged but no documentation on it mbdavid/LiteDB#1108

I'm just wondering if that will help me.

I'm looking to override the default behaviour to be able to ignore documents with a _type where the assembly isn't loaded so it won't deserialise it. I've been looking at custom mappers but I can see how to use the default mapping once I've overridden the mapper for the base type as calling ToDocument and ToObject is a circular reference to the custom mapper (as is Serializer and Deserialize).

1 reply
Natalie Perret
@natalie-perret-1986
I guess i'm too dumb to grasp some basics but regardless, I've ended up posting a question here: mbdavid/LiteDB#2091
Seiko Santana
@seikosantana

https://i.vgy.me/jBy3cn.png
How i can Include a property in array property of my entity?
I Have class Phrase with prop List<Option> and each option have prop Phrase, when i get a Phrase i need include all Phrase in Options.

Would you give this a try?
https://www.nuget.org/packages/LiteDB.Helper.IncludeAll/

It's a small extension class that brings IncludeAll to ILiteCollection<T> hope that helps
m013n
@m013n
Should it be possible to open a shared connection the is used by multiple threads? I've only been able to get this work by using a lock because it seems to deadlock when separate threads are accessing the database. For some reason I thought this was managed by LiteDB.
m013n
@m013n
It does work fine without the lock when the connection is not set to shared but I also need another process to access the database and trying to find a good solution.
Vladimir Rogozhin
@V0v1kkk

Hello.

I need for some advice.
How can I remove N first or N last documents in a collection if I don't know their identifiers?

Donny Velazquez
@donnyv
Is there a way to use regex in queries?
Luigi Bellanca
@g1ga
How can I query a collection of elements with a list inside, based on the length of that list? inefficient way would be col.GetAll().Where(e => e.innerlist.any())
Krzysztof Pajak
@KrzysztofPajak
Hi guys, we thinking to add support LiteDB in our application eCommerce software (https://github.com/grandnode/grandnode2), what are the main advantages of using this kind of database?
Zopenzop
@Zopenzop
I think the major advantages include
  1. Local database
  2. A single database file
  3. Encryption support
  4. Open source
@KrzysztofPajak ^ if that helps
ahmadmdabit
@ahmadmdabit

Hello, I have this model

public class BookDetailedTypeModel : BaseLiteDBModel
    {
        public new static readonly string CollectionName = "book_detailed_types";

        public int DetailedTypeID { get; set; }

        public string DetailedTypeName { get; set; }
        public int BooksCount { get; set; }

        internal static void MappingInit()
        {
            BsonMapper.Global.Entity<BookDetailedTypeModel>()
                .Ctor(/**/) 
                .Id(x => x.DetailedTypeID, true)
                .Field(x => x.DetailedTypeName, "DetailedTypeName")
                .Field(x => x.BooksCount, "BooksCount");
        }
    }

I want to know how I can use ctor in fluent mapping (BsonCtor).

Any help?

Best Regards

ahmadmdabit
@ahmadmdabit

Second question: about DbRef
Here, I have this model

public class CategoryModel : BaseLiteDBModel
    {
        public new static readonly string CollectionName = "categories";

        public int CategoryID { get; set; }
        public string CategoryName { get; set; }
        public int? OrderNumber { get; set; }
        public int BooksCount { get; set; }
        public int? ParentCategoryID { get; set; }

        public virtual CategoryModel ParentCategory { get; set; }

        public CategoryModel()
        {
        }

        [BsonCtor]
        public CategoryModel(int categoryID, string categoryName, int? orderNumber, int booksCount, int? parentCategoryID, CategoryModel parentCategory)
        {
            CategoryID = categoryID;
            CategoryName = categoryName;
            OrderNumber = orderNumber;
            BooksCount = booksCount;
            ParentCategoryID = parentCategoryID;
            ParentCategory = parentCategory;
        }

        internal static void MappingInit()
        {
            BsonMapper.Global.Entity<CategoryModel>()
                //.Ctor(/**/)
                .Id(x => x.CategoryID, true)
                .Field(x => x.CategoryName, "CategoryName")
                .Field(x => x.OrderNumber, "OrderNumber")
                .Field(x => x.ParentCategoryID, "ParentCategoryID")
                .Ignore(x => x.BooksCount)
                .DbRef(x => x.ParentCategory);
        }
    }

and I did these insertions

Collection.Insert(new CategoryModel
            {
                CategoryName = "Category 1",  // Auto id will be : 1
            });
Collection.Insert(new CategoryModel
            {
                CategoryName = "Category 2",
            });
Collection.Insert(new CategoryModel
            {
                CategoryName = "Category 3",
                                ParentCategoryID = 1,
            });

then tried to retrieve them with include but ParentCategory is always null , what's wrong?

Collection.Include(x => x.ParentCategory).Query().ToList();
ParentCategoryID it is not null for Category 3
But ParentCategory is null
Marius
@marhaako
Hi! I currently have a LiteDb running on v5.0.11 in a windows environment, and it is leaking atoms like CRAZY. It starts out just fine, but the more I insert into the database, the more atoms are used by the process.. Just migrated from SqLite which used approx 15 atoms, and using LiteDb it's now 79 and increasing. Does anyone experience the same issue?
agreentejada
@agreentejada
@ahmadmdabit LiteDB doesn't work exactly like EF Core. In order to reference the ParentCategory by ID, you have to actually insert into another table of ParentCategory. A table will not auto-generated just because you inserted a CategoryModel.
In any case, I believe the BsonCtor is largely unnecessary. LiteDB will use the public properties of your class to build up the collection, the only thing you need is the Mapper.
@marhaako LiteDB seems to have some problems with this, the best approach to managing memory leaks is to restrict your inserts to transactions, or use the InsertBulk() functionality provided.
agreentejada
@agreentejada
@KrzysztofPajak Treat it as the same as SQLLite, except with a much higher speed of development (since you're matching C# objects to collections) with EF Core like functionality. We use DbRef all the time and it works like a charm.
@g1ga , I believe there's in the LiteDB Browser, the way to do this would be SELECT COUNT($.Items) FROM Collection WHERE COUNT($.Items) > @Limit. In C#, I believe this would be col.Find(X => X.Items.Count > limit);
Marius
@marhaako
@agreentejada I have already restricted all inserts to transactions and/or InsertBulk operations, and the Global Atom Table still seems to grow and grow
agreentejada
@agreentejada
@marhaako Yeah, I don't know too much about memory, our entries tend to be within 100k items a table.
ahmadmdabit
@ahmadmdabit
@agreentejada Thanks for your feedback...
hidemat
@hidemat
Hello. Just curious for the future. Are there any dev plans to move to .Net 6
teddy-albina
@TeddyAlbina
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 ?
M-Usman-Tariq
@M-Usman-Tariq
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
@figueiredorj
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.
Timothy
@timothyparez
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
@bar10dr_gitlab
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
@DamienDoumer
Hi, does anyone know how to reduce Litedb's memory consumption ?
I'm using it in Xamarin Forms
Timothy
@timothyparez
I am having this weird issue where SELECT $ FROM entries WHERE _id = "28669BD8DB6D8A5C711F8E7FD15DC6C8" returns nothing but `.FindById("28669BD8DB6D8A5C711F8E7FD15DC6C8") does return a document.
Damien Doumer
@DamienDoumer
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
@jwChung
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
@HobDev
Hello All, Is LiteDB ready for DotNet Maui
Timothy
@timothyparez
I am using it on Android, given that it's fully managed code, I'd say 99% it's MAUI ready
nomadev
@nomadev:matrix.org
[m]

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

nomadev
@nomadev:matrix.org
[m]

: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

jerryfan
@jerryfan
Has anyone here used LiteDb for application state management?
bluekuen
@bluekuen

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
@jeeshenlee

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
@jeeshenlee

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
@rafalpiotrowski:matrix.org
[m]
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
@rafalpiotrowski:matrix.org
[m]
BTW. I am calling Checkpoint and I have also set CheckpointSize to 0 to manually call Checkpoint.