Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 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
  • Sep 16 14:22
    500lb-Bench commented #2239
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.
ajay kishore
@ajaykishore666_twitter
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
@tjmoore
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
@tjmoore

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
@thryl
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
@HobDev
Hello all
I want to save ordered items by date in LiteDb like this
IEnumerable<Destination> orderedList = destinations.OrderBy(d => d.TripStartDate);
tripContext.Destinations.Insert(orderedList);
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
@newbiz90:matrix.org
[m]
1 reply
Shahab Ouraie
@th3r0b0t

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;

Questions:
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
@dangergrrl:matrix.org
[m]
Hi :)