framework icon indicating copy to clipboard operation
framework copied to clipboard

Total v4 is not sending operation object when using EXEC

Open LandyCuadra opened this issue 5 years ago • 5 comments

I tried to validate a model using schema.required function, but its always empty.

this is the function my route calls

async function addPracticeOrder() {

  const self = this,
    {body} = self;

  EXEC('+orderPractice --> update', body, function(err, response){
    if(err){
      self.status = 500;
      self.json(err);
      return;
    }

    self.status = 200;
    self.json(response);
  }, self);
}

my schema definition

  schema.define('practice', 'PracticeBase');

  schema.required('practice', (model, op) => {
    console.log(model);
    console.log(op);
  });

in those logs, model has a SchemaValue and operation an Empty Object

Operation
 {}

Model
 SchemaValue {
  practice: SchemaValue {
    name: 'Coral',
    legalAddress: '1535 Sunset Drive Coral Gables, FL 33146',
    status: 'Active',
    products: []
  }
}

Am I doing something wrong?

LandyCuadra avatar Nov 05 '21 18:11 LandyCuadra

Hi @LandyCuadra, here is the repo for Total.js v4: https://github.com/totaljs/framework4

I don't see your entire schema, please send me it - I need to test it.

petersirka avatar Nov 05 '21 18:11 petersirka

Yes, there is a bug. I'm going to fix it. BTW: EXEC() supports promise, just call it without callback.

petersirka avatar Nov 05 '21 18:11 petersirka

I have fixed it, please try it: $ npm install total4@beta and let me know.

petersirka avatar Nov 05 '21 19:11 petersirka

Great it's working fine know, thanks. sorry will submit the next issue to the correct repo

LandyCuadra avatar Nov 05 '21 19:11 LandyCuadra

@LandyCuadra great, and no problem. Thank you for the report.

petersirka avatar Nov 05 '21 22:11 petersirka