diff --git a/package-lock.json b/package-lock.json index eca656c4..fd5cb26d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dyna-record", - "version": "0.0.18", + "version": "0.0.19", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dyna-record", - "version": "0.0.18", + "version": "0.0.19", "license": "MIT", "dependencies": { "@aws-sdk/client-dynamodb": "^3.502.0", diff --git a/package.json b/package.json index 8395cf59..a5ae9351 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dyna-record", - "version": "0.0.18", + "version": "0.0.19", "description": "Typescript Object Relational Mapper (ORM) for Dynamo", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/DynaRecord.ts b/src/DynaRecord.ts index 49492a6a..4ad44117 100644 --- a/src/DynaRecord.ts +++ b/src/DynaRecord.ts @@ -224,7 +224,7 @@ abstract class DynaRecord implements DynaRecordBase { public static async create( this: EntityClass, attributes: CreateOptions - ): Promise { + ): Promise["run"]>> { const op = new Create(this); return await op.run(attributes); } diff --git a/src/operations/Create/Create.ts b/src/operations/Create/Create.ts index f2f3de21..8a0cdfe0 100644 --- a/src/operations/Create/Create.ts +++ b/src/operations/Create/Create.ts @@ -6,6 +6,7 @@ import { entityToTableItem, tableItemToEntity } from "../../utils"; import OperationBase from "../OperationBase"; import { RelationshipTransactions } from "../utils"; import type { CreateOptions } from "./types"; +import { type EntityAttributes } from "../types"; /** * Represents the operation for creating a new entity in the database, including handling its attributes and any related entities' associations. It will handle de-normalizing data to support relationships @@ -27,7 +28,7 @@ class Create extends OperationBase { * @param attributes * @returns */ - public async run(attributes: CreateOptions): Promise { + public async run(attributes: CreateOptions): Promise> { const entityData = this.buildEntityData(attributes); const tableItem = entityToTableItem(this.EntityClass, entityData); diff --git a/tests/integration/Create.test.ts b/tests/integration/Create.test.ts index 35802d97..7f20c06e 100644 --- a/tests/integration/Create.test.ts +++ b/tests/integration/Create.test.ts @@ -815,5 +815,15 @@ describe("Create", () => { myAttribute: null }); }); + + it("relationships are not part of return value", async () => { + const res = await Order.create({ + // @ts-expect-error default fields are not accepted on create, they are managed by dyna-record + createdAt: new Date() + }); + + // @ts-expect-error relationships are not part of return value + console.log(res.paymentMethod); + }); }); });