pocketbase / pocketbase

Open Source realtime backend in 1 file
https://pocketbase.io
MIT License
36.06k stars 1.62k forks source link

Expand isn't working or throwing errors #5045

Closed lukepighetti closed 3 weeks ago

lukepighetti commented 3 weeks ago
Future<void> getDrills() async {
  // tags is a multi-relation, progression_of is a single-relation
  final x = await pb.collection('drills').getFullList(
        fields: 'id,title,tags,progression_of',
        expand: 'tags,progression_of',
      );
  print(x.first.data);
  print(x.first.expand);
  //
}
data: {progression_of: zmjveahr61ltn40, tags: [d1e52n7bdxv3foz, zqb10h1ggft3ni9, yafqui8bh5so6dq, xbeq20vt6mb0dmk], title: Mozambique}
expand: {}

user has access to List and View on all tables in the database

I have three expectations here and none are working:

  1. the multi-relation should expand
  2. the single-relation should expand
  3. if expand points to something user doesn't have access to, or doesn't exist, an error should be thrown

Anything I might be missing?

The rows I'm trying to expand on this table:

Screenshot 2024-06-07 at 6 24 15 PM
lukepighetti commented 3 weeks ago

ok I think I got it, I need to specify the fields on the expanded items!

  final x = await pb.collection('drills').getFullList(
        fields: 'id,title,expand.*',
        expand: 'tags',
      );

or

  final x = await pb.collection('drills').getFullList(
        fields: 'id,title,expand.tags.*',
        expand: 'tags',
      );

or

  final x = await pb.collection('drills').getFullList(
        fields: 'id,title,expand.tags.title',
        expand: 'tags',
      );