Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 14:20
    kcsombrio commented #2250
  • 14:19
    kcsombrio commented #2250
  • 10:25
    arcanelab opened #2259
  • 10:09
    arcanelab closed #2258
  • 10:09
    arcanelab synchronize #2258
  • 10:08
    arcanelab synchronize #2258
  • 09:41
    arcanelab synchronize #2258
  • 09:23
    arcanelab synchronize #2258
  • Dec 05 23:43
    7702244 commented #2250
  • Dec 05 17:11

    lbnascimento on master

    Fix object deserialization when… (compare)

  • Dec 05 10:02
    jackmcbrezel commented #2255
  • Dec 05 10:02
    jackmcbrezel commented #2255
  • Dec 05 10:00
    jackmcbrezel commented #2255
  • Dec 04 17:34
    7702244 commented #2082
  • Dec 02 16:10
    ProKn1fe commented #2255
  • Dec 01 23:12
    arcanelab edited #2258
  • Dec 01 21:16
    jackmcbrezel commented #2255
  • Dec 01 21:15
    jackmcbrezel commented #2255
  • Dec 01 20:56
    arcanelab opened #2258
  • Dec 01 20:02
    ProKn1fe commented #2257
agreentejada
@agreentejada
@jswigart Not in a way that changes performance. If you look at the DBref docs, LiteDB stores reference to other collections in documents. However, there is no JOIN syntax.
But if you're asking if you need to use, please do! I LOVE this project, I write all of my desktop app's caching logic with it
agreentejada
@agreentejada
@dvyas Is IMongoDatabase from the MongoDB library? If so, that's not going to work.
You're going to have to do a lot of work to write an abstraction wrapper between LiteDB and MongoDB. Can I ask what your use case is? If you're just trying to migrate functionality over from MongoDB to LiteDB, I recommend writing an IDatabase interface that then implements either library.
agreentejada
@agreentejada
using System.Collections.Generic;

namespace Connect.DB
{
    public interface IDB<T>
    {
        void Delete(int id);
        IDictionary<int, T> Read();
        T Read(int id);
        void Write(IDictionary<int, T> values, bool overwrite = true);
        void Write(int id, T value, bool overwrite = true);
    }
}
Something like this
Lior Orenbach
@lioror_gitlab
@lbnascimento Can you elaborate about the problem: Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks
What causes to get this error?
cloudb0x
@cloudb0x
Is ther a way to do an OR statement using linq? Dynically adding to the ILiteQueryable
dvyas
@dvyas
What is the way to clear litedb cache after inserting heavy payloads?
it is not freeing up the memory
Monaldcry7788
@Monaldcry7788
Hello, is possible to open the same database with some program? (Like 2 program)
nwarrenfl
@nwarrenfl
Hi, i am just starting out to use LiteDB, however I was wondering how to open Studio?
dvyas
@dvyas
@Fungusware Did u found any solution for slow query, I have created index akso on my query but it is very sow
emelhu
@emelhu
@Monaldcry7788 @Monaldcry7788
dvyas
@dvyas

Hi,

I have a query
var result = users.Query()
.Where(td =>
td.TypeId == "abcd" &&
td.Version.Major == 1 && td.IsDeleted == false);

Which is taking more than 1000ms ( sometimes 5 secs also ) to get the result. The collection is not that big(120 documents).

I have created index also while inserting the documents:
users.EnsureIndex("tdrKeyIndex", "[$.TypeId, $.Version, $.IsDeleted]");

Any hints or help how can I reduce this query time ?

dvyas
@dvyas
The database file size is 4 Mb
Nikita Bokov
@ULTROwaka

Hi, explain to me please. I can't use [BsonCtor] if the constructor has a parameter of any my custom class?
example

 public Constraint(Guid id, DialogueAttribute attribute, object leftValue, object rightValue = null)

DialogueAttribute can`t be deserialized automatically?

Jeremy Swigart
@jswigart
Anyone have a reliable strategy for safely generating a backup of the database while the app that uses it is running?
Nikita Bokov
@ULTROwaka
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.
1 reply
            mapper.Entity<Option>().Id(x => x.Id)
                .DbRef(x => x.NextPhrase, "Phrases");
        public IEnumerable<Phrase> GetInitialPhrases(Character character, Theme theme)
        {         
            return _phrases
//Here i need Include something like Option.NextPhrase
                .Include(x => x.Character)
                .Include(x => x.Theme)
                .Find(x => x.IsInitial && x.Character.Id == character.Id && x.Theme.Id == theme.Id);
        }
Seiko Santana
@seikosantana

I compiled LiteDB.Studio with mono for Linux. I haven't tested much to see if it is stable enough, but here: https://github.com/seikosantana/LiteDB.Studio/releases

And i then noticed there's already LiteDB Portal and it looks much more promising. Seems like not much has noticed that?

knuxbbs
@knuxbbs:matrix.org
[m]
Thanks, @seikosantana
I don't have heard about LiteDB Portal before
But I think that a desktop solution for LiteDB wouldn't be best than an embedded web app
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-o-perret
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...