-
Notifications
You must be signed in to change notification settings - Fork 114
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
With dynamodb-onetable: "2.6.2" If we try and use the return value from create to create another new item, we get a typescript error saying the pk type is incompatible:
Types of property 'pk' are incompatible.
Type 'string | null | undefined' is not assignable to type 'string | undefined'.
Type 'null' is not assignable to type 'string | undefined'.
import { Table, Entity, Model } from 'dynamodb-onetable'
const schema = {
format: 'onetable:1.1.0',
version: '0.0.1',
indexes: {
primary: { hash: 'pk', sort: 'sk' },
},
models: {
SomeModel: {
pk: { type: String, value: 'somemodel' },
sk: { type: String, value: 'somemodel:${field}' },
field: { type: String, required: true },
}
} as const,
params: {
isoDates: true,
timestamps: true,
},
}
type SomeModelType = Entity<typeof schema.models.SomeModel>
const table = new Table({})
const SomeModelModel: Model<SomeModelType> = table.getModel("SomeModel")
const newSomeModel = await SomeModelModel.create({field:"Ok"})
newSomeModel.field = "Not Ok"
const anotherNewSomeModel = await SomeModelModel.create(newSomeModel)
Error is on the last line.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working