Question
RavenDb - working with json / Polymorphic objects
I'd like to store configuration for a plugin system in RavenDb. The data is JSON (specifically, a string containing JSON), and every configuration item has some common data and a lot of implementation specific data. The common data looks like this and every implementation specific configuration derives from this class:
class BaseConfiguration
{
public string Id {get; set;}
public string Name {get; set;}
}
In other NoSqlDbs, when adding, I would construct a BsonDocument based on the JSON string representation of the object derived from BaseConfiguration
and store that in a collection whose name I specify. Similarly, I'd extract the BsonDocument from the same collection, then return the JSON string to my application.
the number of items being saved is small - there's one of each class type and the type is not a known type for the database layer.
so, how'd I go about it? I could also imagine using a BaseConfiguration collection but then I'd need the ability to capture all properties that cannot be deserialized, and turn it back into a Json document.