0

除了数据库表定义之外,我还按照漂移文档中的示例声明了一些视图,并设法完成了生成过程。在那之后,我对抽象视图类的使用感到非常困惑,我既不能实例化它来进行查询,也不能将它合并到查询定义中(get 或 watch)。

abstract class TestingRemoteSignalView extends View {
  TestingRemoteSignal get testingRemoteSignal;
  Bay get bay;
  RemoteSignal get remoteSignal;
  Expression<String> get description => bay.name + remoteSignal.signalName;

  @override
  Query as() {
    return select([
      testingRemoteSignal.id,
      bay.name,
      description,
      testingRemoteSignal.passed,
      testingRemoteSignal.skipped,
      testingRemoteSignal.touched,
      testingRemoteSignal.memo,
    ]).from(testingRemoteSignal).join([
      innerJoin(bay, testingRemoteSignal.bay.equalsExp(bay.id)),
      innerJoin(
          remoteSignal, testingRemoteSignal.signal.equalsExp(remoteSignal.id))
    ]);
  }
}

这些 View 类有什么用以及如何从它们中进行查询?也许是这样的:

final query = select(TestingRemoteSignalView)..where((t) => t.passed.isEquals(true));
query.watch();
4

0 回答 0