Ravendb: Separating Document Id Into A Property Using The Patch Api
It may feel a little dirty to put the same value in both the document id, for example:
id: Users/E41270DC-4E0D-48C2-B3CE-4A51FFB649E3
However, if UserId wasn’t included in the document as a property, then when you go to create an index on Users that needs to load related documents with ids that also contain the user id value, you’ll be in trouble. The closest thing you have to use is the string value of the document id (ie. id: Users/E41270DC-4E0D-48C2-B3CE-4A51FFB649E3). It’s very difficult, if not impossible, to pull the GUID out of the user id string from within the index.
If you do have millions of User documents in your database, and you did not remember to include the UserId property in the document, here’s an easy patch request that will add this UserId property to all of your docs:
blog comments powered by Disqus