Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 27 02:29
    HolyOne commented #1041
  • Oct 25 06:36
    seikosantana commented #1654
  • Oct 24 09:38
    natalie-perret-1986 labeled #2091
  • Oct 24 09:38
    natalie-perret-1986 opened #2091
  • Oct 23 08:11
    jinga69 opened #2090
  • Oct 23 08:11
    jinga69 labeled #2090
  • Oct 22 12:19
    tjmoore commented #1025
  • Oct 22 12:19
    tjmoore commented #1025
  • Oct 22 11:23
    tjmoore commented #1108
  • Oct 22 11:22
    tjmoore commented #1108
  • Oct 22 07:29
    seikosantana labeled #2088
  • Oct 22 07:29
    seikosantana opened #2088
  • Oct 22 06:07
    AndrewJ-DEV commented #2072
  • Oct 22 05:57
    AndrewJ-DEV commented #2072
  • Oct 21 18:42
    tjmoore commented #1108
  • Oct 21 17:54
    thomaslevesque commented #1108
  • Oct 21 17:30
    tjmoore commented #1108
  • Oct 21 07:27
    AndrewJ-DEV commented #2075
  • Oct 21 07:05
    AndrewJ-DEV opened #2087
  • Oct 21 07:01
    AndrewJ-DEV commented #2085
arturcortellijunior
@arturcortellijunior
Invalid Data on 3165995326. Full zero: False. Page Type: 181. Prev/Next: 1231292982/2490937806. UniqueID: 95. ShareCounter: 1.
Jeremy Swigart
@jswigart
Is there any notion of "foreign keys" in this db?
Jeremy Swigart
@jswigart
Also, curious if there in performance information on different sized dbs I could look at?
Sergey
@SergeyCodder

Hey guys! I'm using LiteDb with generic types.
Eg:

public void Update(T entity)
{
    var oldChangeStamp = entity.ChangeStamp;
    var result = _collection.UpdateMany(x => entity, x => x.Id == entity.Id && x.ChangeStamp == oldChangeStamp);
}

And I get such error: Extend expression must return an anonymous class to be merge with entities. Eg: col.UpdateMany(x => new { Name = x.Name.ToUpper() }, x => x.Age > 10)

I don't understand what a problem, because in message above I saw, that using class instead anonymous type is correct.

@NateKomodo I don't know which version you're running, but the example is probably wrong. In the latest version, it is correct: col.UpdateMany(x => new Customer { Name = x.Name.ToUpper(), Salary: 100 }, x => x.Name == "John")

I'm using 5.0.10 version (is latest)
Could you help me?

skhan-nacmgit
@skhan-nacmgit
How does one prune the db? Just fire off a delete on a large collection? I plan on rolling this on a simple application and would like to clear our data older than x months.
DominikGeiler
@DominikGeiler

Hi all i have a question about correct mapping of a class that include a list of a custom class. All data besides the list is stored correct and i can also load it back. is there a special mapping needed? My class looks like this:

[BsonId]
public Guid ID { get; set; } = Guid.NewGuid();
public int CardType { get; set; }
public String Cardname { get; set; }
public int Rack { get; set; }
public int Level { get; set; }
public int Field { get; set; }

    [BsonRef("Articledata")]
    public List<Articledata> CardItems = new List<Articledata>(4);

public class Articledata
{
public int Pos { get; set; }
public String Title { get; set; }
public String Text { get; set; }
public String Description { get; set; }
public String Manufacturer { get; set; }
public String OrderID { get; set; }
public String Picturepath { get; set; }
public String Color1 { get; set; }
public String Color2 { get; set; }
public DateTime Insertdate { get; set; }
public DateTime Expiredate { get; set; }
public float Amount { get; set; }
public float Amountwarning { get; set; }

}

saving like:
public void InsertAVSCARDIntoLightDB(AVSCard Card)
{
string path = Configuration.getDefaultDirectory_online();
path += "AVSCard.db";
// Open database (or create if doesn't exist)
using (var db = new LiteDatabase(path))
{
// Get a collection (or create, if doesn't exist)
var col = db.GetCollection<AVSCard>("AVSCard");

            col.Insert(Card);

        }
    }

loading:

    public void LoadAVSCaardsFromDB()
    {
        list_litedb_cards.Clear();
        list_litedb_cards = new List<AVSCard>();
        string path = Configuration.getDefaultDirectory_online();
        path += "AVSCard.db";

        using (var db = new LiteDatabase(path))
        {
            // Get a collection (or create, if doesn't exist)
            ILiteCollection<AVSCard> db_avscards = db.GetCollection<AVSCard>("AVSCard");

            foreach (var item in db_avscards.FindAll())
            {
                list_litedb_cards.Add(item);
                l_all_card.Add(item);                
            }
        }            
    }
Tim Moore
@tjmoore
Does anyone use a tool to generate data model diagrams from POCO classes? I know there are tools for Entity Framework, but LiteDB is just using simple POCO.
Pavel Anpin
@anpin
Hi everyone! I have weird exception with one of my clients which I can't reproduce locally exception is "System.Exception: LiteDB ENSURE: transaction must be active to rollback (current state: Disposed)". Any thoughts on where to dig would be highly appreciated.
emelhu
@emelhu
@dvyas
You can found a lot of answers here: https://www.litedb.org/ :)
dvyas
@dvyas
Hi, I am looking at abstraction wrapper between mongodb and litedb. Anybody had done this ?
dvyas
@dvyas
Hi , I am trying to create abstraction wrapperbetween litedb and mongodb
public class MonogoClientOverride : IMongoClient
{
public ICluster Cluster => throw new NotImplementedException();
    public MongoClientSettings Settings => throw new NotImplementedException();


    public IMongoDatabase GetDatabase(string name, MongoDatabaseSettings settings)
    {
        return (IMongoDatabase) new LiteDatabase("litedb.db");
    }
but it is giving type casting issue
how can I Make LiteDatabase realize the IMongoDatabase interface
agreentejada
@agreentejada
@skhan-nacmgit I think you have to use .Rebuild() to do some cleanup, but deleting collections should be fine.
I'm working with 500 MB's of LiteDB on my client's desktop app and it seems to work.
agreentejada
@agreentejada
@DominikGeiler Do you need to store the Articledata in another collection? Seems like the best practice to me would be to store it in the initial collection. Also, it's probably faster to do list_litedb_cards = db_avscards.FindAll().ToList();' in yourusing` block. Other than that, looks good!
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-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.