0

when I try to use the beforeSave inside the model, nothing happens, in theory the documentation in my code would have to record 334 in the database, but nothing happens, it saves the value that the user typed in the frontent and not 334.

in the documentation I didn't see any place saying that I need to call the changePrice function somewhere else besides here.

Package version 5.8.0 (adonis core) 18.1.1 (lucid)

Node.js and npm version v18.12.1

Sample Code (to reproduce the issue)

  @column()
  public price: decimal

  @beforeSave()
  public static changePrice(advert: Advert) {
    console.log('Hello beforeSave')
    advert.price = 334.00
  }
Petronio Amaral
  • 171
  • 1
  • 1
  • 7

0 Answers0