dynamodb-toolbox icon indicating copy to clipboard operation
dynamodb-toolbox copied to clipboard

is there a way to disable schema checking temporarily?

Open ahmad-ali14 opened this issue 3 years ago • 2 comments

we don't know our schema well yet; every time we try to save an item with that has a property not defined in the Entity constructor, the operation crashes and the function throws.

we want to be able to disable this error temporarily.

I checked the source code, so I can:

  1. disable autoSave && autoParse on the entity object.
  2. use the Entity functions (put, update) to only generate the objects that dynamodb accepts.
  3. use aws dynamo client to save the item.

I used this:

async function create (obj: Partial<MyType>) {
      entity.autoParse = false;
      entity.autoExecute = false;
     
      /**
      * I want this function to only generate the params without normalizing them
      */
      const params = entity.putParams(obj,);
      const created = await DocumentClient.put(params).promise();
      console.log({ created });
    };

and I still get this error:

    "errorMessage": "Field 'me' does not have a mapping or alias",

anybody have a simpler idea?

ahmad-ali14 avatar May 07 '22 15:05 ahmad-ali14

Hi @jeremydaly is this by design? would be good to know if there's an option to disable this! thank you 🙏

kkarimi avatar May 09 '22 10:05 kkarimi

This was by design, but I suppose we could disable it with a flag. Adding to roadmap.

jeremydaly avatar Jul 07 '22 14:07 jeremydaly

Hey @ahmad-ali14, lately, I've added an option that allows you not to throw an error when an unmapped field is provided, but it does filter it.

It's called strictSchemaCheck. An example of its usage is listed here.

It will be included in the next release.

I'll be closing this issue for now. Feel free to write a message here if you feel that this issue should be re-opened.

naorpeled avatar Aug 17 '22 14:08 naorpeled

@naorpeled Thank you very much

ahmad-ali14 avatar Aug 17 '22 14:08 ahmad-ali14