Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 06 03:23
    FarhadMohseni commented #1329
  • Dec 05 11:09
    guillaume86 edited #2112
  • Dec 05 01:41
    guillaume86 opened #2112
  • Dec 03 07:31
    nphamvn closed #2111
  • Dec 03 04:50
    nphamvn commented #412
  • Dec 03 04:43
    nphamvn opened #2111
  • Dec 03 04:43
    nphamvn labeled #2111
  • Dec 03 04:41
    nphamvn closed #2110
  • Dec 03 04:40
    nphamvn opened #2110
  • Dec 03 04:40
    nphamvn labeled #2110
  • Dec 02 07:50
    Intelli-Soft opened #2109
  • Nov 30 17:44
    cmalpass opened #2108
  • Nov 30 17:44
    cmalpass labeled #2108
  • Nov 29 17:34
    yariker commented #177
  • Nov 27 09:20
    noncom commented #1196
  • Nov 26 22:42
    Jacknq commented #1333
  • Nov 26 09:07
    alex-jitbit commented #2097
  • Nov 26 06:16
    Feofilakt commented #2097
  • Nov 26 04:02
    noncom commented #1196
  • Nov 25 09:29
    superware closed #1107
Leonardo Nascimento
@lbnascimento
It processes all collections in a datafile, transforming ObjectIds into strings. I ran some tests and it seems to run fine - of course, you should do your own testing, to ensure that it works properly and that it fits your needs.
If you have a distributed aplication (like a mobile app), you can use db.UserVersion to determine whether the file has to be processed or not
Tim Moore
@tjmoore
@lbnascimento Cool, thanks for that. I'll give it a go. It does seem like the simplest way to do it.
Nate Komodo
@NateKomodo
How does one use UpdateMany? the example is to use an anonymous type, but i get a type conversion error when i do this
db.GetCollection<Setting>("settings").UpdateMany(s => new { setting.Name, setting.Value }, s => s.Name == setting.Name);
The example is 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)
weirdyang
@weirdyang
col.UpdateMany(x => new Customer { Name = x.Name.ToUpper(), Salary: 100 }, x => x.Name == "John")
image.png
Leonardo Nascimento
@lbnascimento
@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")
Mark Gerrits
@skinny
Hi all! I have been using v5 of LiteDB with pleasure but I'm running into an issue with enums. By default enum values are serialized as strings but that won't work with Linq so I added BsonMapper.Global.EnumAsInteger = true; to my application. That solved the problem with my "first" enum but introduced one for another enum I use. This enum is defined on my class as public DocumentType[] SupportedDocumentTypes { get; set; }
Saving is working, but when retrieving an item from the DB I get : : 'Object cannot be stored in an array of this type.' . Contents of the DB field at the point is : [0,1]
any help would be much appreciated
Leonardo Nascimento
@lbnascimento
@skinny Apparently there's a bug when deserializing enum arrays, I'll fix it shortly
Leonardo Nascimento
@lbnascimento
@skinny It is fixed in the master branch, check it out
Mark Gerrits
@skinny
oh nice! building :)
@lbnascimento works like a charm! Using my local build for now, any ETA on a new nuget release ?
Leonardo Nascimento
@lbnascimento
@skinny Usually we wait a few weeks between minor releases (v5.0.9 was a fluke because we were really busy with features for the next major release)
Mark Gerrits
@skinny
no problem, but just to get my expectations straight :)
thanks again!
Chris Hill
@robotron2084
Hello! I'm wondering if i've found a bug or I'm doing something wrong:
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.