join data from 2 tables into one class

I need some database assistance.

I have the following tables:

Tables

I need to pull out an Event with the data from the EventType Table to assign and Event that has an EventType linked to a User.

I am using Moor and they cater for joins, I just need some assistance with the query. Currently I have been trying this:

Stream<EventWithType> eventWithType(EventData eventTypeId) {
  final query = select(event)
    ..where((tbl) {
      return tbl.id.equals(eventTypeId.id);
    })
   ..join([
     innerJoin(eventType, eventType.id.equals(eventTypeId.eventTypeId)),
   ]);
 }

EventWithType.dart

class EventWithType {

  final EventData event;
  final EventTypeData eventTypeData;

  EventWithType(this.event, this.eventTypeData);
  
}

but I know I am doing something wrong I am just not sure how to do joins, or even if I am using the correct join?

TIA x10sion



Read more here: https://stackoverflow.com/questions/64303899/join-data-from-2-tables-into-one-class

Content Attribution

This content was originally published by x10sion at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: