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

  • Home
  • SEARCH
  • 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 9133353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:28:27+00:00 2026-06-17T08:28:27+00:00

Okay, so I’m working with Couchbase 2.0 and the most recent .NET client. Basically

  • 0

Okay, so I’m working with Couchbase 2.0 and the most recent .NET client.
Basically what I’m writing is a project to keep track of goals (a glorified to-do list)…

I’ve managed to store a goal object as a JSON document within couchbase and then deserialize it back into a POCO, but my question is how to automatically lookup the linked documents and populate the subGoal List<Goal>

Not sure if this kind of automatic deserialization is possible without some logic to handle it within the code itself but any pointers appreciated, cheers!

JSON

{
    id: "goal_1",
    name: "goal 1",
    description: "think of some better projects",
    subGoals: [goal_2, goal_3]
}

C#

var goal = client.GetJson<Goal>(id);
return goal;

Here’s the POCO

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json;

namespace stuff.Models
{
    public class Goal
    {
        protected DateTime _targetDate;

        /// <summary>
        /// Name of the goal
        /// </summary>
        [JsonProperty("name")]
        public String Name { get; set; }

        /// <summary>
        /// Full description of the goal
        /// </summary>
        [JsonProperty("description")]
        public String Description { get; set; }

        /// <summary>
        /// Target date for completing this goal
        /// </summary>
        [JsonProperty("targetDate")]
        public DateTime? TargetDate
        {
            get
            {
                return _targetDate;
            }
            set
            {
                // target date must be later than any sub-goal target dates
            }
        }

        /// <summary>
        /// Any sub-goals
        /// </summary>
        [JsonProperty("subGoals")]
        public List<Goal> SubGoals { get; set; }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="Description"></param>
        /// <param name="TargetDate"></param>
        /// <param name="SubGoals"></param>
        public Goal(String Name, String Description, DateTime? TargetDate = null, List<Goal> SubGoals = null)
        {
            this.Name = Name;
            this.Description = Description;
            this.TargetDate = TargetDate;
            this.SubGoals = SubGoals;
        }
    }
}
  • 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-17T08:28:28+00:00Added an answer on June 17, 2026 at 8:28 am

    There’s no automatic way to get related documents back in one “join” query, however you could use a collated view. So given a set of goals like below (note the addition of a type property):

    {"name":"goal 1","description":"This is a parent goal","subgoals":["goal2","goal3"],"type":"goal"}
    {"name":"goal 2","description":"This is a child goal","type":"goal"}
    {"name":"goal 3","description":"This is another child goal","type":"goal"}
    {"name":"goal 4","description":"This is another parent goal","subgoals":["goal5","goal6","goal7"],"type":"goal"}
    {"name":"goal 5","description":"This is a child goal","type":"goal"}
    {"name":"goal 6","description":"This is a child goal","type":"goal"}
    {"name":"goal 7","description":"This is a child goal","type":"goal"}
    

    You would then write a view that outputs each parent goal followed by its children:

    function (doc, meta) 
    {
      if (doc.type == "goal" && doc.subgoals)
      {
        emit([meta.id, 0], null);
            for(var idx in doc.subgoals)
            {
              emit([doc.subgoals[idx], 1], null);
            }    
      }
    }
    

    The output of this view is a set of rows, where each row contains a key consisting of the parent ID and a 0, followed by its children and a 1 (the 0 and 1 ensure that the rows are ordered correctly):

    {"id":"goal1","key":["goal1",0],"value":null},
    {"id":"goal1","key":["goal2",1],"value":null},
    {"id":"goal1","key":["goal3",1],"value":null},
    {"id":"goal4","key":["goal4",0],"value":null},
    {"id":"goal4","key":["goal5",1],"value":null},
    {"id":"goal4","key":["goal6",1],"value":null}
    

    In the .NET SDK tutorial, I describe how to query a collated view (a Brewery and its beers).

    http://www.couchbase.com/docs/couchbase-sdk-net-1.2/collatedviews.html

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

Sidebar

Related Questions

Okay, so I'm working on a java server for an Apps backend, it must
Okay, So I just started Android development (I am average at VB.Net, so I
Okay, so I have been working on a chat program. Its a WIP doesn't
Okay, this gets a little convoluted, so bear with me. I'll try and keep
Okay so I'm using the jQuery autocomplete working with my database of locations and
Okay so I've been having trouble with my first XML project, so I've turned
Okay, simple situation: I'm writing a simple console application which connects to a SOAP
Okay, so what I have is basically three dynamic drop down boxes and a
Okay so the basically I'm building an application to connect to xero on the
Okay so what I have is a table that keeps track of history on

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.