0
const BaseModel = require("./base_model.js");

class CustomerModel extends BaseModel {

  static get tableName() {
    return "customers";
  }

  static get jsonSchema() {
    return {
      type: "object", required: ['name','phone_number','email'],

      properties: {
        id: { type: "string" },
        name: { type: ["string", "null"], maxLength: 150 },
        phone_number: { type: ["string", "null"] },
        email: { type: ["string", "null"], maxLength: 150 },
        website: { type: ["string", "null"], maxLength: 150 },
        address: { type: ["string", "null"], maxLength: 150 },
        customer_type: { "type": "string" },
        version: { type: ["integer"] },
        synced_at: { "type": ["string", "null"] },
        created_at: { "type": "string" },
        updated_at: { "type": "string" }
      }
    };
  }

  get itemVersion() {
    return false;
  }
}

module.exports = CustomerModel;

I don't want validation to occur when I update the model

Gpak
  • 3,342
  • 2
  • 21
  • 19

1 Answers1

1

to ignore validation use patch, update will validate as if it was an insert and validated against schema

M-Raw
  • 779
  • 4
  • 10
  • That works well, I don't know how I overlooked that instruction on the documentation, appreciate for pointing out this – Gpak Aug 25 '22 at 19:16