In a transaction, how do you ignore generated field requirements?

Ttheogravity5/22/2023
export interface TextDocumentTable {
  id: Generated<number>;
  created_at: Generated<Date>;
}

export interface TextDocumentChunkTable {
  id: Generated<number>;
  text_document_id: number;
  created_at: Generated<Date>;
  text: string;
}

export type TextDocumentRow = Selectable<TextDocumentTable>;
export type TextDocumentChunkRow = Selectable<TextDocumentChunkTable>;


await this.db.transaction().execute(async (trx) => {

  // 2nd param is TextDocumentRow
  const insertedTextDocument = await insertTextDocument(trx, document);

  // 2nd param is TextDocumentChunkRow
  await insertTextDocumentChunk(trx, {
    text_document_id: insertedTextDocument.id,
    text: document.text_content,
  });
});


Typescript will complain that insertTextDocumentChunk needs id and created_at even though they are Generated values.
Solution
Oohmi5/22/2023
im assuming id/created_at are nullable on document
Oohmi5/22/2023
while the generated schema is expecting them to not be null
Ttheogravity5/22/2023
Ah. That's what I'm missing. Silly mistake
Ttheogravity5/22/2023
Thank you
Ttheogravity5/22/2023
Actually, I figured out what was really wrong - I shouldn't have had to add an optional on those fields.

I was using Selectable<TextDocumentTable> and Selectable<TextDocumentChunkTable> for the insert inputs for insertTextDocument / insertTextDocumentChunk when it should be using Insertable instead of Selectable