Brightspot CMS Developer Guide

Object references


Dari supports querying relationships using the field/subfield path notation in where methods. The following models demonstrate the use case of finding all activities for a particular user. In these models, the Activity.activityUser field is of type User.

public class Activity extends Record {

    @Indexed private Date activityDate;
    @Indexed private User activityUser;
    @Indexed private String groupLead;

     /* Getters and setters */
 }

public class User extends Record {

    @Indexed private String name;

    /* Getters and setters */
}

There are two ways to find activities by a specific user. You can first query for the user, and then query for activities by that user.

/* Get the user */
User user = Query.from(User.class).where("name = 'John Smith'").first();

/* Get the user's list of activities */
List<Activity> activities = Query.from(Activity.class).where("activityUser = ?", user).selectAll();

A second, more efficient way, is to use a single query that incorporates path notation.

List<Activity> activities = Query.from(Activity.class)
            .where("activityUser/name = 'John Smith'")
            .selectAll();

Previous Topic
Binding variables
Next Topic
Sorting
Was this topic helpful?
Thanks for your feedback.
Our robust, flexible Design System provides hundreds of pre-built components you can use to build the presentation layer of your dreams.

Asset types
Module types
Page types
Brightspot is packaged with content types that get you up and running in a matter of days, including assets, modules and landing pages.

Content types
Modules
Landing pages
Everything you need to know when creating, managing, and administering content within Brightspot CMS.

Dashboards
Publishing
Workflows
Admin configurations
A guide for installing, supporting, extending, modifying and administering code on the Brightspot platform.

Field types
Content modeling
Rich-text elements
Images
A guide to configuring Brightspot's library of integrations, including pre-built options and developer-configured extensions.

Google Analytics
Shopify
Apple News