mbdavid / LiteDB

LiteDB - A .NET NoSQL Document Store in a single data file
http://www.litedb.org
MIT License
8.62k stars 1.25k forks source link

v5 questions #1336

Open vshapenko opened 5 years ago

vshapenko commented 5 years ago

Hello! I am writing litedb wrapper for f#, and have some questions about upcoming v5 version of litedb.

  1. Is BsonValue.RawValue intentionally made internal? If so, is there a way to get raw value now?. I am badly need this for enum case.
  2. Same question for BsonValue(object). This was very handy in some cases.
mbdavid commented 5 years ago

Hi @vshapenko, both changes was made to remove from user pottencial bad-use of BsonDocument.

But if you need it in F# conversion, it's possible change this or maybe create another class like BsonValueWrapper that contains access to this RawValue and implement ctor for Object

vshapenko commented 5 years ago

Sounds like a good idea.

пт, 11 окт. 2019 г., 16:01 Mauricio David notifications@github.com:

Hi @vshapenko https://github.com/vshapenko, both changes was made to remove from user pottencial bad-use of BsonDocument.

But if you need it in F# conversion, it's possible change this or maybe create another class like BsonValueWrapper that contains access to this RawValue and implement ctor for Object

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mbdavid/LiteDB/issues/1336?email_source=notifications&email_token=AEKNDOSUG2IS4BH62OTTYYLQOB2JLA5CNFSM4I7MKGOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEA75PHA#issuecomment-541054876, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEKNDOR5JBXBVTUQN37YAOLQOB2JLANCNFSM4I7MKGOA .

nightroman commented 4 years ago

The author of Mdbc is here. (Mdbc is the PowerShell wrapper of the official MongoDB C# driver).

I recently discovered LiteDB, found it fascinating, and I am now thinking (exploring?) the similar wrapper for LiteDB.

I must tell that LiteDB v5 API is PowerShell friendly right out of the box, at least comparing to the MongoDB C# driver v2. But there are numerous nuisances, not faults of the LiteDB design, just the PowerShell reality.

One of the nuisances is the mentioned absence of the public RawValue of BsonValue. PowerShell would be very happy to get just object. After all, working with raw objects is what PowerShell does. But this not possible at the moment. Extracting the real value is tedious, too difficult for such a basic operation.

Using returned BsonValues in PowerShell is not a practical option. Even though they sometimes behave "like real objects/values", the type is not "native" and it should be unwrapped ASAP to avoid various issues.

both changes was made to remove from user pottencial bad-use of BsonDocument.

It sounds wise and cautious. But the reality is, these are needed in practice. So people have to implement their own type switch conversion blocks to do these (object <-> BsonValue) in every use case, with some pain and mistakes.

It might be better to expose this correct functionality, even if misuse is possible. What were the cases of misuse in practice?

nightroman commented 4 years ago

Some thoughts on minimizing misuses of hopefully restored features.

BsonValue.RawValue is already in a good shape, in my opinion. It is not implicit. If I type it, I get what I ask for, an object that I need for whatever reason raw. Please consider making it public.

BsonValue(object) looks not quite right with its implicit nature. Then a static method with some proper unambiguous name would do the trick is a safe way. For example, Convert, TryConvert, or even both?

mbdavid commented 4 years ago

Hi @nightroman, I will check is it's possible make this public as get only.... I'm planning to create a immutable version of BsonDocument/BsonArray so I need to check if this will not open a possible to be changed.

nightroman commented 4 years ago

@mbdavid, thank you, I am looking forward to this or something else for object <-> BsonValue.

P.S. If I proceed with creating LiteDB module for PowerShell, I need to create the PowerShell friendly wrapper of BsonDocument, namely IDictionary<string, object>. It has to unwrap and wrap BsonValues internally. Input and output values must be object in order to be PowerShell friendly.

nightroman commented 4 years ago

Just in case, the MongoDB C# driver's BsonValue exposes RawValue as get only and provides the static Create(object). I am not saying that LiteDB should follow. But the similar precedent exists.

alemik commented 4 years ago

Hi, my project (https://alemik.com/) is based entirely on RawValue and BsonValue(object). I am almost ready to release a new version 0,8 with many features. Please please please please consider to restore those features.