Saturday, October 13, 2012

QueryAll in RavenDB

RavenDB is an awesome NoSQL product, if you don’t know it, I strongly suggest you take a look at it. It tries to be safe by default, which is at great idea, but sometimes you just need to get more than 1024 documents. Yes, this could indicate a misuse of RavenDB, but again sometimes it is needed, and the only way to do this in RavenDB is to use paging.

It is easy enough to do paging, but it requires some code and could easily be implemented in an extension method like this:

It extends an IRavenQueryable with a QueryAll method which uses paging to get all results of the query.

It should be use with great care, this totally circumvents the safe-by-default design implemented in RavenDB, and the results are iterated when calling QueryAll, so after this call the database aren’t hit anymore. Use it as you please, but be careful, it can ruin performance and should only be used when strictly necessary.

No comments:

Post a Comment