Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8292015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:19:21+00:00 2026-06-08T13:19:21+00:00

I have something like this in RavenDb: Path [hasMany] Goals [hasMany] Achievements So I

  • 0

I have something like this in RavenDb:

Path [hasMany] Goals [hasMany] Achievements

So I have one document that contains goals and achievements.

If it where a traditional database, I could make this query

select g.id, count(a.id)
from path p
join goals g on p.id = g.pathId
join achievement a on a.id = g.id
group by goal.id

How do I do this query in ravendb?

Right now I’m doing it like this:

Path path = RavenSession.Load<Path>(pathId);

path.Goals.Select(x => new
{
    Id = x.Id,
    Name = x.Name,
    TOnCourse = x.Achievements.Where(y => y.Resolution == Resolution.OnCourse).Count(),
    TAstray = x.Achievements.Where(y => y.Resolution == Resolution.Astray).Count()
});

I don’t want to do it this way, because I think that I’m loading all the “Goals” and “Achievements” and what I only want is to make the aggregation in the DB (ravendb)

If you want to know what Path, Goals and Achievements really are in my model here is my “pet” project http://dpath.apphb.com/

EDIT
I think I will get those “calculated” values and put them in Goal as properties, because I think the calculation is going to be very common, so keeping it simple since an achievement cannot be deleted, and the user will have a “relation” with goal and the quantity of achievements in order to get “My Stats”

Nevertheless, I would like to know how would you accomplish that query in RavenDb

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:19:24+00:00Added an answer on June 8, 2026 at 1:19 pm

    You are loading just a single document for this, so that is likely to not be an issue.
    You aren’t loading anything else.

    You can do this in an index, and then load the stored fields from there, but I don’t think you need this unless your document is very large.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have documents in RavenDb that may look something like this: { Id: obj/1,
I have a document class that contains a list of tags. Something like: class
I have something like this in one of my views <li <?php $isCurrent ?
I have something that looks like the following document structure: public class Document {
I have a class that looks something like this: public class MyClass { string
I have a model that looks something like this public class User { public
I have something like this that is incorect: vector<boost::thread> vec; for(int agent = 1;
I have something like this: function showFunction () { // need position and place
I have something like this: <?xml version=1.0 encoding=utf-8?> <Data> <ConfigDatas> <ArrayOfConfigData xmlns:i=http://www.w3.org/2001/XMLSchema-instance xmlns=http://schemas.datacontract.org/2004/07/BTTest.Models> <ConfigData>
I have something like this: [{'date': 1, 'value':5}, {'date':2,'value':3}, ...] and want to map

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.