Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: deps is not iterable at Model.runTemplates #454

Closed
vhuty opened this issue Feb 28, 2023 · 0 comments
Closed

TypeError: deps is not iterable at Model.runTemplates #454

vhuty opened this issue Feb 28, 2023 · 0 comments
Labels
bug Something isn't working fixed Issue has been fixed in the repo

Comments

@vhuty
Copy link

vhuty commented Feb 28, 2023

Summary:

When calling Model.init the following error is thrown:

TypeError: deps is not iterable
      at Model.runTemplates (/opt/nodejs/node_modules/dynamodb-onetable/dist/cjs/Model.js:1554:27)
      at Model.initItem (/opt/nodejs/node_modules/dynamodb-onetable/dist/cjs/Model.js:930:14)
      at Model.init (/opt/nodejs/node_modules/dynamodb-onetable/dist/cjs/Model.js:643:21)

Example:

const ItemSchema = {
  version: "0.0.1",
  indexes: {
    primary: { hash: "PK", sort: "SK" },
    GSI0: { hash: "G0PK", sort: "G0SK" },
    GSI1: { hash: "G1PK", sort: "G1SK" },
  },
  params: {
    typeField: "G0PK",
    timestamps: true,
    isoDates: true,
    createdField: "createdAt",
    updatedField: "updatedAt",
  },
  models: {
    Item: {
      PK: { type: String, hidden: true, value: "Item#${id}" },
      SK: { type: String, hidden: true, value: "Item#${id}" },
      G0SK: { type: String, hidden: true, value: "Item#${createdAt}#${id}" },
      G1PK: { type: String, hidden: true, value: "ItemByName#${countryCode}" },
      G1SK: { type: String, hidden: true, value: "Item#${enabled}#${nameLowerCase}#${id}" },
      id: { type: String, required: true },
      name: { type: String, required: true },
      nameLowerCase: { type: String, required: true },
      countryCode: { type: String, required: true },
      enabled: { type: String, required: false, default: "ENABLED" },
      description: { type: String, required: true },
      branding: {
        type: Object,
        required: false,
      },
      info: {
        type: Object,
        required: false,
      },
      lang: {
        type: String,
        enum: ["en", "de"],
      },
      orders: {
        type: Object,
        required: false,
      },
      orderCodes: {
        type: Set,
      },
      createdAt: { type: Date },
      updatedAt: { type: Date },
    },
  } as const,
};

const table = new Table({
    client: new Dynamo({ client: new DynamoDBClient({}) }),
    name: "items",
    schema: ItemSchema,
    partial: false,
  });

const ItemModel = table.getModel<Item>("Item");
const item = ItemModel.init(unmarshalledRecord); // throws Error

Environment:

  • OS: AWS Lambda (x86_64)
  • Node Version: 16.x
  • OneTable Version: 2.6.1
  • TypeScript Version: ~4.4.3
@dev-embedthis dev-embedthis added the bug Something isn't working label Mar 8, 2023
@dev-embedthis dev-embedthis added the fixed Issue has been fixed in the repo label Mar 8, 2023
@dev-embedthis dev-embedthis reopened this Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Issue has been fixed in the repo
Projects
None yet
Development

No branches or pull requests

3 participants