flutter moor - 更新 table 特定行中的特定列

flutter moor - update specific column in specific row of table

我需要替换 moor 数据库中特定行的特定列中的值,但我不知道它是查询。你能举个例子吗?

这是answer你想做的是:

Future moveImportantTasksIntoCategory(Category target) {
  // for updates, we use the "companion" version of a generated class. This wraps the
  // fields in a "Value" type which can be set to be absent using "Value.absent()". This
  // allows us to separate between "SET category = NULL" (`category: Value(null)`) and not
  // updating the category at all: `category: Value.absent()`.
  return (update(todos)
      ..where((t) => t.title.like('%Important%'))
    ).write(TodosCompanion(
      category: Value(target.id),
    ),
  );
}

如果看不懂。检查我的例子:

  updateHeaderId(String customerCode, int headerId) {
    update(offlineOrderLines)
      ..where((tbl) => tbl.custCode.equals(customerCode))
      ..write(OfflineOrderLinesCompanion(headerId: Value(headerId)));
  }

在上面的示例中,我想更改特定 customerCodeheaderId。如果您有任何问题,请告诉我。