Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 09:05
    martin-slater opened #2084
  • 09:05
    martin-slater labeled #2084
  • 09:04
    martin-slater commented #2083
  • 07:34
    sburgara commented #1601
  • 07:29
    martin-slater labeled #2083
  • 07:29
    martin-slater opened #2083
  • Oct 15 05:30
    nshanb commented #2076
  • Oct 15 03:48
    ryancheung commented #844
  • Oct 14 14:10
    Irvinaby commented #1162
  • Oct 14 08:32
    nameofSEOKWONHONG commented #2076
  • Oct 14 07:34
    nameofSEOKWONHONG commented #2049
  • Oct 13 18:30
    rajapc commented #1762
  • Oct 13 17:54
    rajapc commented #1762
  • Oct 13 13:15
    ryancheung opened #2082
  • Oct 13 13:15
    ryancheung labeled #2082
  • Oct 13 12:56
    nabeelio commented #2017
  • Oct 13 12:30
    mhgamework opened #2081
  • Oct 13 06:37
    OneCyrus commented #1416
  • Oct 13 06:33
    rikkitook commented #1416
  • Oct 13 06:32
    rikkitook commented #1416
Chris Hill
@robotron2084
In BsonValue:
public BsonDocument AsDocument => this as BsonDocument;
Is there some kind of override that will convert a BsonValue into a BsonDocument that I'm not seeing?
In the code I've written I've created a BsonValue by doing new BsonValue(myBsonDocument) and it is throwing a null exception on case BsonType.Document: return this.AsDocument.GetBytesCount(recalc); during the upsert.
Leonardo Nascimento
@lbnascimento
@robotron2084 Could you provide more info? Like what is the value of myBsonDocument?
Chris Hill
@robotron2084

To be clear, the issue I'm seeing is that the above code is trying to cast the BsonValue as a BsonDocument....which I don't see how that would ever work. To answer your question:

The BsonDocument passed to the BsonValue is created like so:

BsonDocument ToBsonDocument()
{
  BsonDocument retVal = new BsonDocument();
  retVal["x"] = x;
  retVal["y"] = y;
  return retVal;
}
Floowey
@Floowey
hey, I have an issue where my database becomes unreadable with a System.NotSupportedException: BSON type not supported
It happened twice on the same of my users entries; after the first time I thought I had found the issue but a few hours later if happened again. Is there any way to see what the offending string is?
Leonardo Nascimento
@lbnascimento
@robotron2084 BsonDocument inherits from BsonValue, so it should work whenever it is actually a document, returning null otherwise
4 replies
@Floowey Could you send me your data file?
Floowey
@Floowey
@lbnascimento yes, but I'm new to gitter. Let me try figuring out how to dm you
that didn't work out as I thought it would
let me know if there's anything else you need, you could also dm me on discord (Floowey#0205)
ASPNIC
@ASPNIC
I'm trying to store Serilog's LogEvent in LiteDB, but there is an issue with fetching the objects back as the LogEvent class contains another class that has no public constructors with no parameters. So it doesn't know how to deserialize it. I solved the json Serializing/Deserializing with newtonsoft by telling newtonsoft how to deserialize that specific class, but that doesn't work for LiteDB. Any ideas on how to solve this?
I guess I could use newtonsoft to serialize it and then store it as a string, and then deserialize the string on fetch, but I'd much prefer to skip that step if at all possible somehow
ASPNIC
@ASPNIC
What am I doing wrong here? Object reference not set to an instance of an object on serializing?
BsonMapper.Global.RegisterType<LogEvent>(
    serialize: (LogEvent) => new BsonValue(JsonConvert.SerializeObject(LogEvent)),
    deserialize: (BsonValue) => JsonConvert.DeserializeObject<LogEvent>(BsonValue.AsString, new LogEventJsonConverter(), new LogEventPropertyValueConverter())
);
Leonardo Nascimento
@lbnascimento
@ASPNIC Your custom serializer converts LogEvent to a BsonValue containing a string. While this is supported (and even useful in some instances), you won't be able to have LogEvent as the top-level object in a collection, you would only be able to use it as a sub-object.
You can't have a collection of "loose" BsonValues like string or int, you can only insert BsonDocuments in a collection
If you want to centralize the actual serialize/deserialize logic in Newtonsoft while still being able to use the class normally in LiteDB, you could do something like this:
Leonardo Nascimento
@lbnascimento
BsonMapper.Global.RegisterType<LogEvent>(
    serialize: (LogEvent) => LiteDB.JsonSerializer.Deserialize(JsonConvert.SerializeObject(LogEvent)),
    deserialize: (BsonValue) => JsonConvert.DeserializeObject<LogEvent>(BsonValue.AsDocument.ToString(), new LogEventJsonConverter(), new LogEventPropertyValueConverter())
);
WTTSoftwareSolutions
@WTTSoftwareSolutions
I noticed that the Delete methods on both the LiteRepository and the LiteCollection do not accomodate Delete<T>(T Entity, string collectionName) or DeleteMany<T>(IEnumerable<T> entities, string collectionName) as input. My class handles passing entities through to the LiteRepository but does not know anything about the entities passed in, so I can not get the id to pass in or to create a predicate. Is there a way to pass in an entity to be deleted?
Carlo Kok
@carlokok
LiteDB.LiteException: Invalid Data on 39099. Full zero: False. Page Type: Index. Prev/Next: 4294967295/4294967295. UniqueID: 20147. ShareCounter: 1.
at LiteDB.Engine.DataPage..ctor (LiteDB.Engine.PageBuffer buffer) [0x00017] in <ca87e3e06962463fb463e94e3bd88728>:0
at LiteDB.Engine.BasePage.ReadPage[T] (LiteDB.Engine.PageBuffer buffer) [0x000b7] in <ca87e3e06962463fb463e94e3bd88728>:0
Wbat does this mean and how can i fix ir?
Leonardo Nascimento
@lbnascimento
@WTTSoftwareSolutions Unfortunately this is currently not possible, I believe you may need to use something like Reflection to get the id. We'll consider adding an overload that takes the entity and gets its id for future versions.
@carlokok Could you send me your datafile?
Carlo Kok
@carlokok
@lbnascimento it's fairly large
(320mb)
Is there like a "recover" tool that I can use to recover it ?
Leonardo Nascimento
@lbnascimento
@carlokok There is no recovery tool, we're actually thinking of making something like that. In the meantime, you can send me the data file and I'll take a look a it, see what can be done. You should get pretty good compression on LiteDB data files.
Helmut Wahrmann
@hwahrmann

Need your help on deserializing a List.
i create dynamically a query and get the result like this:

var resultSet = _store.Execute(sql).ToEnumerable().Select(s => BsonMapper.Global.Deserialize<SongData>(s)).ToList();

In my SongData class i have:

public List<string> PictureHashList => _pictureHashList;

Using LiteDBStudio i can see that i have values in the list, but the above query returns an empty list.
Any ideas?

Leonardo Nascimento
@lbnascimento
@hwahrmann This is happening because the property PictureHashList doesn't have a public setter. The easiest fix is to simply create a public setter for it.
Leonardo Nascimento
@lbnascimento
@hwahrmann Actually, in the latest version of LiteDB, you don't even need a public setter, a private setter is enough. Having no setter at all (making it read-only) is a problem, though.
Helmut Wahrmann
@hwahrmann
@lbnascimento Problem solved. thanks for the quick answer
thejayman
@thejayman
Quick question if I may concerning the AutoId. I've designed my own serializing method to turn my class into a BsonDocument and I leave out the Id field so that the AutoId will set an appropriate Id for me. But, how can I force it to provide an int id instead of an ObjectId?
thejayman
@thejayman
Figured it out. I went through the source code for an hour or two and pieced together how it all worked. Turned out to be ridiculously simple and I'm almost embarrassed that I hadn't seen it. I can pass a selected AutoId in when I instantiate the collection.
using var _db = new LiteDatabase(_path); var _dbCol = _db.GetCollection("CollectionName", BsonAutoId.Int32);
weirdyang
@weirdyang

Left expression MAP($.Properties.customer.Properties[*]=>@.FirstName) returns more than one result. Try use ANY or ALL before operant.

can someone help me iwth this query?
SELECT $ FROM LogMessage where $.Properties.customer.Properties[*].FirstName = "Jonathan"

Leonardo Nascimento
@lbnascimento
@captmomo$.Properties.customer.Properties[*].FirstName will return the FirstName of every document in $.Properties.customer.Properties
If you want to check whether any of these are equal to a value, you can use $.Properties.customer.Properties[*].FirstName any = 'Jonathan'. Similarly, if you want to check whether all of these are equal to a value, you can use $.Properties.customer.Properties[*].FirstName all = 'Jonathan'
weirdyang
@weirdyang
thank you!
Martin Vseticka
@MartyIX
Hi, has Mauricio David stopped developing LiteDB? I don't see any commits of his lately.
Mauricio David
@mbdavid
Hi Martin, I’m working in another project now, so I’m with no free time now. Maybe two more weeks and I will back with LiteDB development. For now, Leonardo works with me and if he needs any help he calls me.
Martin Vseticka
@MartyIX
I see, thank you for your answer! Thanks for you work on LiteDB!
Mi.Chi
@AlessioMiky76_twitter
Hi, this query works fine "select $.Car.doc0.name from TestQuery". It returns the value of name, doc0 is a sub document inside subdocument Car. How can i modifiy query to select all subdocuments inside Car and not only doc0 and get the values of name of all those subdocuments?
Mi.Chi
@AlessioMiky76_twitter
I've tried SELECT $.Car[*].name FROM TestQuery. No error are raised but result is empty. There are 8 subdocuments in Car with a [name] field
Ghost
@ghost~593a87c3d73408ce4f66068b
hi, was litedb stress tested with a million items in a collection? does it scale?
also, is it possible to store items sorted using a timestamp?
Jbm
@JbMarchal_twitter
HI, I have a similar question :) Is LiteDB an in-memory database? When we perform a (read) query, is there any physical disk usage or is everything done in memory? Thanks for these informations ;)
Piet Eckhart
@pietsoftwaretogo
Hi, A week ago I've asked about the date for upcomming release on github: mbdavid/LiteDB#1810
Does anyone have an answer?
Leonardo Nascimento
@lbnascimento
@AlessioMiky76_twitter This sort of query (iterating through values in a document) is currently not supported. You would have to create some code that does it.
@AlessioMiky76_twitter I believe it could be supported with some small changes to the SQL parser, I'll look into it.
Leonardo Nascimento
@lbnascimento
@raizam There is a LiteDB.Benchmarks project in our solution, which can be use to measure performance. We ran some tests earlier this year, but I can't seem to find the results, sorry about that.