Jestor.update() help

Hi Guys,

We are having some trouble implementing the ‘Jestor.update()’ native method in different functions throughout our low-code.
Here is a simple example of our code that isn’t working*:
Screen Shot 2022-01-13 at 19.10.48

This example pretty much mimics your’s example in your Docs: Native Methods

*Funny thing is: Even though we get an error 500, the rest of the code present in the function works (above Jestor.update line). Here is the response:
{
“status”: false,
“data”: {
“message”: “An Internal Error Has Occurred.”,
“url”: “/webhook/OGIwMGMwZmIwNGZkZDExea069be6a7MTY0MDIwMTU5ODE3ODAz”,
“code”: 500
},
“metadata”: {
“response”: “An Internal Error Has Occurred.”,
“message”: “An Internal Error Has Occurred.”,
“org”: “quartoavista”,
“notifications”: []
}
}

@fernando.nakandakari @renato.menegasso could you guys help us out here?

the same is happening is for Jestor.remove. We’ve noticed that in the official documentation the id is always an integer ex:

$vendorupdate = array(
  "id_vendors" => 1,
    "email" => "firstvendor@email.com",
);
Jestor.update("vendors",$vendorupdate);

In our case the id is a text field. That is the only difference I can see.

Hey @danielcspaiva

You’re right about the difference: the id in Jestor.create() and Jestor.update() should always be integers! That’s because this id isn’t the default field you see when you create a table (which is identified as ‘name’). It’s the true id of the record (basically, its “row” in Jestor’s database).

You can learn more about it here: The hidden id field

We use this id for those methods because it’s always non-repeatable, which won’t always be the case with ‘name’.

So in your case, assuming I’m getting the table’s name right, this should work:

$id = $searchReservation[0]['id_reservas_2'];
$reservationUpdated = array(
   "id_reservas_2" => $id,
   "total" => 870
);
Jestor.update("reservas_2",$reservationUpdated);

For the Jestor.remove, same thing. The difference is that you won’t pass an array, but the id directly, I believe. The code below would delete the entire record:

$id = $searchReservation[0]['id_reservas_2'];
Jestor.remove("reservas_2",$id);

Let me know if you have any other questions :slight_smile:

2 Likes