Skip to content

Is it possible to define an object in your schema with unknown/dynamic keys? #428

Answered by mobsense
alexedwardjones asked this question in Q&A
Discussion options

You must be logged in to vote

If you don't know the key, you can use a generated ID and then fetch based on ID and filter on name. That works okay for a small number of books.

A separate model is the way to go. If the book name is unique, use that in the key:

models: {
    Book: {
        pk:               { type: 'string', value: 'book#${name}' },
        sk:               { type: 'string', value: 'book#' },
        name:         { type: 'string' }
        pages:        { type: 'number', default: 0 },
      

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dev-embedthis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants