开发者

RavenDB: Convert a document property to another type

开发者 https://www.devze.com 2023-03-30 00:21 出处:网络
I\'m currently developing an application where I change the document a lot as I go forward (a small project to learn stuff like RavenDB). Some changes are not backwards compatible, which leads to JSON

I'm currently developing an application where I change the document a lot as I go forward (a small project to learn stuff like RavenDB). Some changes are not backwards compatible, which leads to JSON deserialization failures when I try to fetch documents.

Are there some way that I convert a property from the old type to a new one during deserialization? I'm using Raven.Client.Lightweight as client library.

Example:

I had a property named AllProperties in a class which was a Dictionary<string,string>. I c开发者_StackOverflow社区hanged the type from dictionary to a class called MetadataItemCollection.


As in any other database-solution I suggest you roll your favourite migrations-framework for such kind of things. You will probably want to do set-based operations on documents.

Interesting is, Ayende is going to publish two articles about ravendb migrations in the next few days, however, google has already indexed them and you can access these articles here:

RavenDB Migrations: When to execute?

RavenDB Migrations: Rolling Updates

Ayende, please forgive me... ;)


If you are doing this during development, you are probably better off just deleting old docs and recreating them If you are doing this in production, take a look at the posts that dlang has posted, they discuss those specific issues.

0

精彩评论

暂无评论...
验证码 换一张
取 消