khonsulabs / bonsaidb

A developer-friendly document database that grows with you, written in Rust
https://bonsaidb.io/
Apache License 2.0
1.03k stars 37 forks source link

Would you consider linktime registration of collections #300

Open ModProg opened 1 year ago

ModProg commented 1 year ago

I just found https://github.com/dtolnay/linkme and thought that this might allow collections to register themselves at a schema instead of the other way round. (e.g. the derive macro could do this) if no outright support, maybe a way to specify a [fn(&mut Schematic) -> Result] that define_collections would iterate over and execute.

Just an idea, currently don't really have any projects of the scale where it would be beneficial to register collections distributedly.

(though I did forget to register views or collections from time to time, so in the case of a full integration that would have saved me the headache of not understanding why my code not working) :D

ecton commented 1 year ago

Yes, but not as the default path due to some of the open issues (e.g., 61, 49). It seems like tracking down some of the issues from that could be tricky from an end-user's perspective.

I would also think that this could be used to register Views in their respective collections too.

The last complicating factor is that collections can be used in multiple schemas.