withOnly method

  1. @override
QueryBuilderInterface<T> withOnly(
  1. List<String> relations
)
override

Replaces the model's defaultRelations with the specified list.

This ignores any default relations defined on the model and only loads exactly what is specified here.

// Model has defaultRelations: ['posts', 'profile']
final users = await UserModel.q<UserModel>()
  .withOnly(['roles'])  // Only loads 'roles', ignoring defaults
  .get();

Implementation

@override
QueryBuilderInterface<T> withOnly(List<String> relations) {
  _withOnly.addAll(relations);
  return this;
}