New build notes

99 views
Skip to first unread message

Ayende Rahien

unread,
Feb 23, 2011, 7:44:32 AM2/23/11
to ravendb
There are a few things that are new in this build.

  • There aren't any builtin indexes any longer.
    If you want to get the Raven/DocumentsByEntityName, you can create it explicitly by calling:
    new Raven.Client.Indexes.RavenDocumentsByEntityName().Execute(documentStore)
  • It should fix the write error that some people experienced.
  • It fix a race condition between disposing and flushing the indexes (usually only happened at shutdown).
  • Replication failover changed - now it will not replicate writes by default, you can modify this behavior using DocumentConventions.FailoverBehavior
  • You can now query by id prefix (gimme all documents start with "users/123/friends"

Chris Marisic

unread,
Feb 23, 2011, 9:01:25 AM2/23/11
to rav...@googlegroups.com
inline


On Wednesday, February 23, 2011 7:44:32 AM UTC-5, Ayende Rahien wrote:
  • You can now query by id prefix (gimme all documents start with "users/123/friends"

Can you elaborate on a scenario where you would use this? I'm not really following

Ayende Rahien

unread,
Feb 23, 2011, 2:50:06 PM2/23/11
to Chris Marisic, rav...@googlegroups.com
This was needed for the Silverlight client, mostly
Real world usage include nested documents
For example you can store all of the posts comments in posts/245/comments/1 , posts/245/comments/2
And then you can query for all the associates comments using startsWith=posts/246/comments

Sent from my Windows Phone

From: Chris Marisic
Sent: Wednesday, February 23, 2011 4:01 PM
To: rav...@googlegroups.com
Subject: [RavenDB] Re: New build notes

Chris Marisic

unread,
Feb 24, 2011, 8:52:14 AM2/24/11
to rav...@googlegroups.com, Chris Marisic
What would your models and interaction with Raven look like that you would have posts/245/comments/1 , posts/245/comments/2?

Ayende Rahien

unread,
Feb 24, 2011, 9:25:59 AM2/24/11
to rav...@googlegroups.com
Totally separated documents, but they can be queried efficiently in this manner.

Chris Marisic

unread,
Feb 24, 2011, 10:16:22 AM2/24/11
to rav...@googlegroups.com
So you would have

Post { ... }
Comment { ... }

session.Save(new Post())
session.Save(new Comment())

What would have to be done that raven positions these documents that you get posts/245/comments/1?

Matt Warren

unread,
Feb 24, 2011, 11:29:34 AM2/24/11
to ravendb
Yeah I'm interested in this a well, it looks like a nice feature.

My guess is that it's just a convention thing, i.e. RavenDB doesn't
automatically put the post and comments together for you.

So you have to do the work of creating the start of the comment url
(i.e. posts/245/comments/) and putting together all the comments for a
post. But you can do it easier because it's based on the convention of
the url.

But I'm only guessing?

Chris Marisic

unread,
Feb 24, 2011, 11:36:43 AM2/24/11
to rav...@googlegroups.com
This seems like the optimal solution for hosting Blog/Comments, Question/Answer type models, of course I have no idea how it's put into practice.

Ayende Rahien

unread,
Feb 24, 2011, 12:35:07 PM2/24/11
to rav...@googlegroups.com
You would either override the conventions for generating an id for comments or do that manually.

Matt Warren

unread,
Feb 24, 2011, 12:32:46 PM2/24/11
to ravendb
Me neither, I guess we'll just wait for Oren to enlighten us ;-)

Chris Marisic

unread,
Feb 24, 2011, 3:37:10 PM2/24/11
to rav...@googlegroups.com
I'd really like to see an example of this

Ayende Rahien

unread,
Feb 25, 2011, 10:46:38 AM2/25/11
to rav...@googlegroups.com
var documentStore = new DocumentStore();
var generator = new MultiTypeHiLoKeyGenerator(documentStore, 1024);
documentStore.Conventions.DocumentKeyGenerator = entity =>
{
    var documentKey = generator.GenerateDocumentKey(documentStore.Conventions, entity);
    var comment = entity as Comment;
    if (comment != null)
    {
        return comment.PostId + "/" + documentKey;
    }
    return documentKey;
};
documentStore.Initialize();

Chris Marisic

unread,
Mar 1, 2011, 2:49:33 PM3/1/11
to rav...@googlegroups.com
Now that is really really cool.

In regards to the conventions features, is there a convention that lets you change the entity separator? If you want client-1 instead of client/1?

Ayende Rahien

unread,
Mar 1, 2011, 6:02:09 PM3/1/11
to ravendb, Chris Marisic
Yes, IdentitySeperator, IIRC, or something like that

Matt Warren

unread,
Mar 2, 2011, 4:28:06 AM3/2/11
to ravendb
The actual code is:
documentStore.Conventions.IdentityPartsSeparator = "-";

On Mar 1, 11:02 pm, Ayende Rahien <aye...@ayende.com> wrote:
> Yes, IdentitySeperator, IIRC, or something like that
>
> On Tue, Mar 1, 2011 at 9:49 PM, Chris Marisic <ch...@marisic.com> wrote:
> > Now that is really *really *cool.

Chris Marisic

unread,
Feb 22, 2012, 10:02:22 AM2/22/12
to rav...@googlegroups.com, Chris Marisic
As question relevant to current raven. Supposing you have a Post document, its id is "posts/1", with raven you can do session.Load<Post>(1)  and it correctly loads the document.

If you changed the conventions as you outlined that you have a comment whos id is "posts/245/comments/2" and you do session.Load<Comment>(2)  does that work?

Itamar Syn-Hershko

unread,
Feb 22, 2012, 1:38:53 PM2/22/12
to rav...@googlegroups.com
How would it know the post ID?

The method you refer to uses  Conventions.FindFullDocumentKeyFromNonStringIdentifier to get a string ID (default implementation is DefaultFindFullDocumentKeyFromNonStringIdentifier), so by default you'll get posts/2
Reply all
Reply to author
Forward
0 new messages