When querying the database, I receive the document type as a return.
const table: TableDocument = await this.tableSchema.create({ ...createTableDto })
console.log(table)
The structure of the table object is as follows:
{
createdBy: '12',
capacity: 4,
tableNumber: 5,
_id: new ObjectId("618bdb1ab2e5813b6f1fc198"),
createdAt: 2021-11-10T14:45:46.279Z,
updatedAt: 2021-11-10T14:45:46.279Z,
__v: 0
}
However, I am facing an issue accessing the updatedAt property in my code.
table.__v exists
table.updatedAt does not exist on this type: TableDocument
If possible, I would like to declare to TypeScript that I am returning a custom type:
const table: ResponseTable = await this.tableSchema.create({ ...createTableDto })
Although the error "Table Document is not assignable to ResponseTable..." occurs.
I am struggling to find a solution with Mongoose 6.0 TypeScript support