0

I'm trying to save an item to DynamoDB table using dynogels Orm with joi for types. One of the properties of the saved item is files which is an array. Initially, I would like this value to be an empty array.

const projectSchema: SchemaType = {
  name: joi.string().optional(),
  description: joi.string().optional().allow(null, ""),
  **files: joi.array().default([ ]),**
  user: joi.alternatives().try(joi.object(), joi.string()).required(),
  config: joi.object().optional(),
  background: joi.string().optional().allow(null, ""),
  status: joi.string().optional(),
  metadata: joi.object(),
  key: joi.string().optional(),
  email: joi.string().optional(),
  published: joi.boolean().default(true),
};

ive tried as seen above, and also by chaining other functions like valid(), allow(). also ive tried to remove the array() and replaced it with any() but nothing seems to work. The item is being saved to the database without the files.

Is there anyone who had experience with that?

1 Answers1

0

I've not used nor heard of dynogels before, but it seems to be a fork of Vogels which does not support list types: https://github.com/clarkie/dynogels#schema-types

Seems you need to either use a number-set of string-set, and if this assumption on dynogels is correct, and you must use a set, DynamoDB does not allow empty sets. You would have to store an empty string within the set: [""]

Leeroy Hannigan
  • 11,409
  • 3
  • 14
  • 31