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

Allow custom TypeDescriptor field #1982

Closed skadefro closed 4 months ago

skadefro commented 3 years ago

Is your feature request related to a problem? Please describe. I want to use lidedb as a local cache for a system that uses mongodb as a backed. But I already use _type for something else and that gives issues with litedb.

Describe the solution you'd like I would like to suggest adding a TypeDescriptor property on the BsonMapper class to allow a custom name for this field

Describe alternatives you've considered Have not considered any alternatives

Additional context I have opened a pull request with the suggested feature.

mbdavid commented 3 years ago

Hi @skadefro,

If you are mapping documents between two databases that need this same _type column you need to consider create a custom BsonMapper class that use this new rules. You need to use a single object instance of this class in your LiteDatabase ctor.

skadefro commented 3 years ago

Hi mbdavid, I'm sorry if I'm missing something obvious, but I tried copying the BsonMapper class with my updates, to my own project, so I can use it in the LiteDatabase constructor. But that will not work since LiteDB.Constants, LiteDB.Reflection, LiteDB.LinqExpressionVisitor and maybe more are all internal.

skadefro commented 4 months ago

I created a fork with this work around. I'll close this issue to not keep issue open that will not be fixed/implemented.