hhblaze / DBreeze

C# .NET NOSQL ( key value store embedded ) ACID multi-paradigm database management system.
BSD 2-Clause "Simplified" License
532 stars 58 forks source link

DBreeze sorts by ID #58

Closed AbdisamadMoh closed 5 years ago

AbdisamadMoh commented 5 years ago

Hi DBreeze team, Im very new to dbreeze world and i found it simple, fast and reliable database. Im trying to store users chats, but the problem im facing is that dbreeze seems to sort them my id(ID i used) which i dnt want. Here is the code i used to query using LINQPAD

var db = new DBreeze.DBreezeEngine(@"File");
    using(var tr = db.GetTransaction())
    {
    var s = tr.SelectForward<string, DbMJSON<Message>>("ToAli").Select(x=>x.Value.Get).Dump();

    }
    db.Dispose();

image

I dont know if approaching in a wrong way, it is sorting by ID. I want the message to be the way they r inserted without any sorting.

Am i doing in a wrong approach? what to do?

hhblaze commented 5 years ago

Hi, you should really start from the docu. DBreeze automatically sorts by inserted key, so if you want records to be sorted by insert sequence use as a key growing up integer 1,2,3. In your case you will need probably minimum two indexes, one is to assure the sorting by adding sequence, second to search by MessageID: use object DBreeze for that. Example is here

AbdisamadMoh commented 5 years ago

Thank you very much. I have one more issue. Should I comment here or create new issue?

hhblaze commented 5 years ago

Thank you very much. I have one more issue. Should I comment here or create new issue?

As you wish

AbdisamadMoh commented 5 years ago

Thank you. I will create new issue, it may help someone else who have same problem.