insert method

Future<int> insert(
  1. Session session,
  2. dynamic items, {
  3. List<Object>? columns(
    1. C columns
    )?,
  4. bool? upsert,
  5. bool? onConflictDoNothing,
})

Implementation

Future<int> insert(
  Session session,
  /* R | List<R> */ items, {
  List<Object>? Function(C columns)? columns,
  bool? upsert,
  bool? onConflictDoNothing,
}) async {
  final query = doInsert(
    table: this,
    rows: (items is Iterable ? items : [items])
        .map((e) => e is R ? e.toColumnMap() : e),
    columns:
        (columns == null ? null : columns(this.columns)) ?? this.columns.$all,
    keyColumns: this.columns.$pks,
    upsert: upsert,
    onConflictDoNothing: onConflictDoNothing,
  );
  final rs = await session.executeQuery(query);
  return rs.affectedRows;
}