The type of model this relation builder works with
Type definition for dynamic scope methods that can be added at runtime. Allows for custom query scopes to be added to the builder.
Creates a new relation builder instance. Sets up the query builder and configures the resource path.
The model instance to build relations for
Query builder instance for constructing API requests
Optional
resource: stringOptional custom resource name for the relation
Query builder instance for constructing API URLs and managing query parameters. Used internally to build the request URL and parameters.
Protected
relatedThe related model instance that this builder operates on. Used to create new instances of the related model.
Protected
fluentityProtected
Gets the Fluentity instance for making API requests. Provides access to the singleton instance that manages API communication.
The singleton Fluentity instance
Adds filter conditions to the query. Supports more complex filtering operations than where().
Object containing filter conditions
The relation builder instance for chaining
Fetches a model instance by ID from the API. Makes a GET request to retrieve the model data.
The ID of the model to fetch
A promise that resolves to the fetched model instance
Gets a model instance by ID without making an API request. Creates a new model instance with the given ID for local operations.
The ID of the model to get
A new model instance with the given ID
Limits the number of results returned. Restricts the query to return at most n results.
The maximum number of results to return
The relation builder instance for chaining
Sets the offset for pagination in the query results. Skips n records before starting to return results.
The number of records to skip
The relation builder instance for chaining
Adds an order by clause to the query. Sorts the results by the specified field and direction.
The field to order by (default: 'id')
The direction to order in ('asc' or 'desc', default: 'asc')
The relation builder instance for chaining
Adds a where clause to the query. Filters results based on exact field-value matches.
Object containing field-value pairs to filter by
The relation builder instance for chaining
Base class for building and managing relationships between models. Provides methods for querying related models and building API requests. This class is extended by HasOneRelationBuilder and HasManyRelationBuilder to implement specific relationship behaviors.
Example