You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a model that has a number of nullable fields that should be optional to pass when calling create on the repository:
class UserReportModel {
public readonly id!: number;
public readonly projectId!: string;
public readonly createdAt!: Date;
public readonly description?: string;
public readonly version?: string;
}
The id is a serial so I'm doing the suggested removing it from params:
The null values are handled by node-postgres as null values, not undefined, so you would need to change the type:
description: string|null;
In the default create method, everything is indeed made mandatory but can be nullable. undefined values would mean that those fields are not specified in the INSERT instruction (thus relying on the default database values).
I am closing this issue since I added the missing piece of information in the README file. Let me know if you have other questions or problems, and I will reopen it.
I have a model that has a number of nullable fields that should be optional to pass when calling create on the repository:
The id is a serial so I'm doing the suggested removing it from params:
When I go to create I get type errors:
Looks like because the create attributes are
Required
here:https://github.com/Seb-C/kiss-orm/blob/master/src/Repositories/CrudRepository.ts#L97
The text was updated successfully, but these errors were encountered: